From c5940793c0b0ec4682a83836afc2b508e4233049 Mon Sep 17 00:00:00 2001 From: rasoolkhan16 Date: Mon, 6 Sep 2021 16:33:09 +0530 Subject: [PATCH 01/36] Translate 1-if-else-required --- .../15-function-basics/1-if-else-required/solution.md | 3 ++- .../15-function-basics/1-if-else-required/task.md | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/1-js/02-first-steps/15-function-basics/1-if-else-required/solution.md b/1-js/02-first-steps/15-function-basics/1-if-else-required/solution.md index e41c80418..bb54ffb54 100644 --- a/1-js/02-first-steps/15-function-basics/1-if-else-required/solution.md +++ b/1-js/02-first-steps/15-function-basics/1-if-else-required/solution.md @@ -1 +1,2 @@ -No difference. \ No newline at end of file +No difference. +कोई फर्क नहीं। diff --git a/1-js/02-first-steps/15-function-basics/1-if-else-required/task.md b/1-js/02-first-steps/15-function-basics/1-if-else-required/task.md index 4f69a5c8c..c1d83124c 100644 --- a/1-js/02-first-steps/15-function-basics/1-if-else-required/task.md +++ b/1-js/02-first-steps/15-function-basics/1-if-else-required/task.md @@ -4,9 +4,13 @@ importance: 4 # Is "else" required? +# क्या "else" आवश्यक है? + The following function returns `true` if the parameter `age` is greater than `18`. +यदि `age` पैरामीटर `18` से अधिक है, तो निम्नलिखित फ़ंक्शन `true` लौटाता है। Otherwise it asks for a confirmation and returns its result: +अन्यथा, यह एक पुष्टिकरण मांगता है और अपना परिणाम देता है: ```js function checkAge(age) { @@ -22,6 +26,7 @@ function checkAge(age) { ``` Will the function work differently if `else` is removed? +यदि `else` हटा दिया जाता है तो क्या फ़ंक्शन अलग तरह से काम करेगा? ```js function checkAge(age) { @@ -36,3 +41,4 @@ function checkAge(age) { ``` Is there any difference in the behavior of these two variants? +क्या इन दोनों रूपों के व्यवहार में कोई अंतर है? From e2877f1df13ceae3727a009a4172c3b932e52661 Mon Sep 17 00:00:00 2001 From: rasoolkhan16 Date: Mon, 6 Sep 2021 17:16:26 +0530 Subject: [PATCH 02/36] Translate 2-rewrite-function-question0or --- .../2-rewrite-function-question-or/solution.md | 9 ++++++--- .../2-rewrite-function-question-or/task.md | 12 ++++++++++-- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/1-js/02-first-steps/15-function-basics/2-rewrite-function-question-or/solution.md b/1-js/02-first-steps/15-function-basics/2-rewrite-function-question-or/solution.md index c8ee9618f..de7e5ce37 100644 --- a/1-js/02-first-steps/15-function-basics/2-rewrite-function-question-or/solution.md +++ b/1-js/02-first-steps/15-function-basics/2-rewrite-function-question-or/solution.md @@ -1,17 +1,20 @@ Using a question mark operator `'?'`: +प्रश्न चिह्न ऑपरेटर का उपयोग करते हुए `?`: ```js function checkAge(age) { - return (age > 18) ? true : confirm('Did parents allow you?'); + return age > 18 ? true : confirm("Did parents allow you?"); } ``` Using OR `||` (the shortest variant): +OR ऑपरेटर का उपयोग करते हुए `||` (सबसे छोटा संस्करण) ```js function checkAge(age) { - return (age > 18) || confirm('Did parents allow you?'); + return age > 18 || confirm("Did parents allow you?"); } ``` -Note that the parentheses around `age > 18` are not required here. They exist for better readabilty. +Note that the parentheses around `age > 18` are not required here. They exist for better readabiltiy. +ध्यान दें कि यहां `age > 18` के आसपास के कोष्ठकों की आवश्यकता नहीं है। वे बेहतर पठनीयता के लिए मौजूद हैं। diff --git a/1-js/02-first-steps/15-function-basics/2-rewrite-function-question-or/task.md b/1-js/02-first-steps/15-function-basics/2-rewrite-function-question-or/task.md index 46da079c0..507d8d07e 100644 --- a/1-js/02-first-steps/15-function-basics/2-rewrite-function-question-or/task.md +++ b/1-js/02-first-steps/15-function-basics/2-rewrite-function-question-or/task.md @@ -1,26 +1,34 @@ -importance: 4 +importance: 2 --- # Rewrite the function using '?' or '||' +# '?' या '||' का उपयोग करके फ़ंक्शन को फिर से लिखें| + The following function returns `true` if the parameter `age` is greater than `18`. +यदि `age` पैरामीटर `18` से अधिक है, तो निम्नलिखित फ़ंक्शन `true` लौटाता है। Otherwise it asks for a confirmation and returns its result. +अन्यथा, यह एक पुष्टिकरण मांगता है और अपना परिणाम देता है: ```js function checkAge(age) { if (age > 18) { return true; } else { - return confirm('Did parents allow you?'); + return confirm("Did parents allow you?"); } } ``` Rewrite it, to perform the same, but without `if`, in a single line. +इसे फिर से लिखें, वही प्रदर्शन करने के लिए, लेकिन बिना `if` के, एक पंक्ति में। Make two variants of `checkAge`: +'checkAge' के दो प्रकार बनाएं: 1. Using a question mark operator `?` 2. Using OR `||` +3. प्रश्न चिह्न ऑपरेटर का उपयोग करते हुए `?` +4. OR ऑपरेटर का उपयोग करते हुए `||` From 722a4e1818bc20d0c1261a87828dca4b29d3cacb Mon Sep 17 00:00:00 2001 From: Rasool Khan <35368463+rskhan167@users.noreply.github.com> Date: Mon, 6 Sep 2021 17:18:26 +0530 Subject: [PATCH 03/36] fix numbering --- .../15-function-basics/2-rewrite-function-question-or/task.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/1-js/02-first-steps/15-function-basics/2-rewrite-function-question-or/task.md b/1-js/02-first-steps/15-function-basics/2-rewrite-function-question-or/task.md index 507d8d07e..0ff9fb2cb 100644 --- a/1-js/02-first-steps/15-function-basics/2-rewrite-function-question-or/task.md +++ b/1-js/02-first-steps/15-function-basics/2-rewrite-function-question-or/task.md @@ -30,5 +30,5 @@ Make two variants of `checkAge`: 1. Using a question mark operator `?` 2. Using OR `||` -3. प्रश्न चिह्न ऑपरेटर का उपयोग करते हुए `?` -4. OR ऑपरेटर का उपयोग करते हुए `||` +1. प्रश्न चिह्न ऑपरेटर का उपयोग करते हुए `?` +2. OR ऑपरेटर का उपयोग करते हुए `||` From 906f4e80d7611cb6484d3723d26c808b51c584dd Mon Sep 17 00:00:00 2001 From: Rasool Khan <35368463+rskhan167@users.noreply.github.com> Date: Mon, 6 Sep 2021 17:22:13 +0530 Subject: [PATCH 04/36] fix autochange done by IDE --- .../2-rewrite-function-question-or/solution.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/1-js/02-first-steps/15-function-basics/2-rewrite-function-question-or/solution.md b/1-js/02-first-steps/15-function-basics/2-rewrite-function-question-or/solution.md index de7e5ce37..f73af505b 100644 --- a/1-js/02-first-steps/15-function-basics/2-rewrite-function-question-or/solution.md +++ b/1-js/02-first-steps/15-function-basics/2-rewrite-function-question-or/solution.md @@ -3,7 +3,7 @@ Using a question mark operator `'?'`: ```js function checkAge(age) { - return age > 18 ? true : confirm("Did parents allow you?"); + return (age > 18) ? true : confirm('Did parents allow you?'); } ``` @@ -12,7 +12,7 @@ OR ऑपरेटर का उपयोग करते हुए `||` (सब ```js function checkAge(age) { - return age > 18 || confirm("Did parents allow you?"); + return (age > 18) || confirm('Did parents allow you?'); } ``` From 0c4bd5efb20c93a5bfc755d95ee33269f76c46c6 Mon Sep 17 00:00:00 2001 From: Rasool Khan <35368463+rskhan167@users.noreply.github.com> Date: Mon, 6 Sep 2021 17:27:49 +0530 Subject: [PATCH 05/36] fix changes made by IDE --- .../15-function-basics/2-rewrite-function-question-or/task.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/1-js/02-first-steps/15-function-basics/2-rewrite-function-question-or/task.md b/1-js/02-first-steps/15-function-basics/2-rewrite-function-question-or/task.md index 0ff9fb2cb..bd204330c 100644 --- a/1-js/02-first-steps/15-function-basics/2-rewrite-function-question-or/task.md +++ b/1-js/02-first-steps/15-function-basics/2-rewrite-function-question-or/task.md @@ -1,4 +1,4 @@ -importance: 2 +importance: 4 --- @@ -17,7 +17,7 @@ function checkAge(age) { if (age > 18) { return true; } else { - return confirm("Did parents allow you?"); + return confirm('Did parents allow you?'); } } ``` From 1e5439efe10cf69110e9b14f114d5c028f342f50 Mon Sep 17 00:00:00 2001 From: rskhan167 Date: Mon, 6 Sep 2021 17:45:15 +0530 Subject: [PATCH 06/36] Translate 3-min --- .../15-function-basics/3-min/solution.md | 5 ++++- 1-js/02-first-steps/15-function-basics/3-min/task.md | 11 +++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/1-js/02-first-steps/15-function-basics/3-min/solution.md b/1-js/02-first-steps/15-function-basics/3-min/solution.md index 2236d9203..f46c297bb 100644 --- a/1-js/02-first-steps/15-function-basics/3-min/solution.md +++ b/1-js/02-first-steps/15-function-basics/3-min/solution.md @@ -1,4 +1,5 @@ A solution using `if`: +`if` का उपयोग करके एक हल: ```js function min(a, b) { @@ -11,6 +12,7 @@ function min(a, b) { ``` A solution with a question mark operator `'?'`: +प्रश्न चिह्न ऑपरेटर `'?'` के साथ एक हल: ```js function min(a, b) { @@ -18,4 +20,5 @@ function min(a, b) { } ``` -P.S. In the case of an equality `a == b` it does not matter what to return. \ No newline at end of file +P.S. In the case of an equality `a == b` it does not matter what to return. +नोट: समानता `a == b` के मामले में यह मायने नहीं रखता कि क्या लौटाया जाए। diff --git a/1-js/02-first-steps/15-function-basics/3-min/task.md b/1-js/02-first-steps/15-function-basics/3-min/task.md index 50edd0d36..7e9f72961 100644 --- a/1-js/02-first-steps/15-function-basics/3-min/task.md +++ b/1-js/02-first-steps/15-function-basics/3-min/task.md @@ -4,13 +4,16 @@ importance: 1 # Function min(a, b) +# फंक्शन min(a, b) + Write a function `min(a,b)` which returns the least of two numbers `a` and `b`. +एक फ़ंक्शन लिखें `min(a,b)` जो कम से कम दो नंबर `a` और `b` लौटाता है। For instance: +उदाहरण के लिए: ```js -min(2, 5) == 2 -min(3, -1) == -1 -min(1, 1) == 1 +min(2, 5) == 2; +min(3, -1) == -1; +min(1, 1) == 1; ``` - From f0d15ad9052ba4f1dc975bbc1219e22ac1a7921a Mon Sep 17 00:00:00 2001 From: Rasool Khan <35368463+rskhan167@users.noreply.github.com> Date: Mon, 6 Sep 2021 17:46:48 +0530 Subject: [PATCH 07/36] fix autochange by IDE --- 1-js/02-first-steps/15-function-basics/3-min/task.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/1-js/02-first-steps/15-function-basics/3-min/task.md b/1-js/02-first-steps/15-function-basics/3-min/task.md index 7e9f72961..b6910a40d 100644 --- a/1-js/02-first-steps/15-function-basics/3-min/task.md +++ b/1-js/02-first-steps/15-function-basics/3-min/task.md @@ -13,7 +13,7 @@ For instance: उदाहरण के लिए: ```js -min(2, 5) == 2; -min(3, -1) == -1; -min(1, 1) == 1; +min(2, 5) == 2 +min(3, -1) == -1 +min(1, 1) == 1 ``` From 952f4472e059682c9a51cb24401ecbf0cbbcc73a Mon Sep 17 00:00:00 2001 From: rskhan167 Date: Fri, 10 Sep 2021 00:35:47 +0530 Subject: [PATCH 08/36] Translate article --- .../15-function-basics/4-pow/task.md | 6 +- .../15-function-basics/article.md | 270 +++++++++--------- 2 files changed, 144 insertions(+), 132 deletions(-) diff --git a/1-js/02-first-steps/15-function-basics/4-pow/task.md b/1-js/02-first-steps/15-function-basics/4-pow/task.md index f569320c7..26b090f09 100644 --- a/1-js/02-first-steps/15-function-basics/4-pow/task.md +++ b/1-js/02-first-steps/15-function-basics/4-pow/task.md @@ -4,7 +4,7 @@ importance: 4 # Function pow(x,n) -Write a function `pow(x,n)` that returns `x` in power `n`. Or, in other words, multiplies `x` by itself `n` times and returns the result. +एक function लिखें `pow(x,n)` जो `x` को `n` के शक्ति में लौटाता है। या, दूसरे शब्दों में, `x` को अपने आप से `n` गुणा से गुणा करता है और परिणाम देता है। ```js pow(3, 2) = 3 * 3 = 9 @@ -12,8 +12,8 @@ pow(3, 3) = 3 * 3 * 3 = 27 pow(1, 100) = 1 * 1 * ...* 1 = 1 ``` -Create a web-page that prompts for `x` and `n`, and then shows the result of `pow(x,n)`. +एक वेब-पेज बनाएं जो `x` और `n` के लिए संकेत देता है, और फिर `pow(x,n)` का परिणाम दिखाता है। [demo] -P.S. In this task the function should support only natural values of `n`: integers up from `1`. +नोट: इस टास्क में function को केवल `n` के प्राकृतिक मान का समर्थन करना चाहिए: `1` से ऊपर के पूर्णांक। diff --git a/1-js/02-first-steps/15-function-basics/article.md b/1-js/02-first-steps/15-function-basics/article.md index b12d0b9e7..1c635dd49 100644 --- a/1-js/02-first-steps/15-function-basics/article.md +++ b/1-js/02-first-steps/15-function-basics/article.md @@ -1,26 +1,28 @@ # Functions -Quite often we need to perform a similar action in many places of the script. +अक्सर हमें स्क्रिप्ट के कई स्थानों पर इसी तरह की कार्रवाई करने की आवश्यकता होती है। -For example, we need to show a nice-looking message when a visitor logs in, logs out and maybe somewhere else. +उदाहरण के लिए, जब कोई परिदर्शक इन करता है, लॉग आउट करता है और शायद कहीं और एक अच्छा दिखने वाला संदेश दिखाना चाहता है। -Functions are the main "building blocks" of the program. They allow the code to be called many times without repetition. +Functions प्रोग्राम के मुख्य "बिल्डिंग ब्लॉक्स" हैं। वे बिना दोहराव के कोड को कई बार कॉल करने की अनुमति देते हैं। -We've already seen examples of built-in functions, like `alert(message)`, `prompt(message, default)` and `confirm(question)`. But we can create functions of our own as well. +हम पहले से ही बिल्ट-इन function के उदाहरण देख चुके हैं, जैसे `अलर्ट (संदेश)`, `प्रॉम्प्ट (संदेश, डिफ़ॉल्ट)` और `पुष्टि करें (प्रश्न)`। लेकिन हम अपने स्वयं के functions भी बना सकते हैं। ## Function Declaration -To create a function we can use a *function declaration*. +## Function घोषणा -It looks like this: +function बनाने के लिए हम एक _function declaration_ का उपयोग कर सकते हैं। + +यह इस तरह दिख रहा है: ```js function showMessage() { - alert( 'Hello everyone!' ); + alert("सभी को नमस्कार!"); } ``` -The `function` keyword goes first, then goes the *name of the function*, then a list of *parameters* between the parentheses (comma-separated, empty in the example above) and finally the code of the function, also named "the function body", between curly braces. +`function` कीवर्ड पहले जाता है, फिर _name of the function_ जाता है, फिर कोष्ठक के बीच _parameters_ की एक सूची (उपरोक्त उदाहरण में खाली) और अंत में function का कोड, जिसे "the function body" भी कहा जाता है , घुंघराले ब्रेसिज़ के बीच। ```js function name(parameters) { @@ -28,13 +30,13 @@ function name(parameters) { } ``` -Our new function can be called by its name: `showMessage()`. +हमारे नए function को इसके नाम से बुलाया जा सकता है: `showMessage()`। -For instance: +उदाहरण के लिए: ```js run function showMessage() { - alert( 'Hello everyone!' ); + alert( 'सभी को नमस्कार!' ); } *!* @@ -43,103 +45,107 @@ showMessage(); */!* ``` -The call `showMessage()` executes the code of the function. Here we will see the message two times. +`showMessage()` कॉल करने से function के कोड को निष्पादित करता है। यहां हम संदेश को दो बार देखेंगे। -This example clearly demonstrates one of the main purposes of functions: to avoid code duplication. +यह उदाहरण स्पष्ट रूप से function के मुख्य उद्देश्यों में से एक को प्रदर्शित करता है: कोड आवृत्ति से बचने के लिए। -If we ever need to change the message or the way it is shown, it's enough to modify the code in one place: the function which outputs it. +यदि हमें कभी भी संदेश या उसके दिखाए जाने के तरीके को बदलने की आवश्यकता होती है, तो यह कोड को एक ही स्थान पर संशोधित करने के लिए पर्याप्त है: वह function जो इसे आउटपुट करता है। ## Local variables -A variable declared inside a function is only visible inside that function. +## लोकल variables + +किसी function के अंदर घोषित एक variable केवल उस function के अंदर ही दिखाई देता है। -For example: +उदाहरण के लिए: ```js run function showMessage() { *!* - let message = "Hello, I'm JavaScript!"; // local variable + let message = "हैलो, मैं जावास्क्रिप्ट हूँ!"; // local variable */!* alert( message ); } -showMessage(); // Hello, I'm JavaScript! +showMessage(); // हैलो, मैं जावास्क्रिप्ट हूँ! -alert( message ); // <-- Error! The variable is local to the function +alert( message ); // <-- Error! variable function के लिए स्थानीय है ``` ## Outer variables -A function can access an outer variable as well, for example: +## बाहरी variables + +एक function बाहरी variable को भी एक्सेस कर सकता है, उदाहरण के लिए: ```js run no-beautify let *!*userName*/!* = 'John'; function showMessage() { - let message = 'Hello, ' + *!*userName*/!*; + let message = 'नमस्ते, ' + *!*userName*/!*; alert(message); } -showMessage(); // Hello, John +showMessage(); // नमस्ते, John ``` -The function has full access to the outer variable. It can modify it as well. +function के पास बाहरी variable तक पूर्ण पहुंच है। यह इसे बदल भी कर सकता है। -For instance: +उदाहरण के लिए: ```js run let *!*userName*/!* = 'John'; function showMessage() { - *!*userName*/!* = "Bob"; // (1) changed the outer variable + *!*userName*/!* = "Bob"; // (1) बाहरी variable बदल दिया let message = 'Hello, ' + *!*userName*/!*; alert(message); } -alert( userName ); // *!*John*/!* before the function call +alert( userName ); // *!*John*/!* फ़ंक्शन कॉल से पहले showMessage(); -alert( userName ); // *!*Bob*/!*, the value was modified by the function +alert( userName ); // *!*Bob*/!*, मान function द्वारा संशोधित किया गया था ``` -The outer variable is only used if there's no local one. +बाहरी variable का उपयोग केवल तभी किया जाता है जब कोई लोकल न हो। -If a same-named variable is declared inside the function then it *shadows* the outer one. For instance, in the code below the function uses the local `userName`. The outer one is ignored: +यदि function के अंदर एक ही नामित variable घोषित किया गया है तो यह _shadows_ बाहरी है। उदाहरण के लिए, नीचे दिए गए कोड में function लोकल `userName` का उपयोग करता है। बाहरी को अनदेखा किया जाता है: ```js run let userName = 'John'; function showMessage() { *!* - let userName = "Bob"; // declare a local variable + let userName = "Bob"; // एक local variable घोषित करें */!* let message = 'Hello, ' + userName; // *!*Bob*/!* alert(message); } -// the function will create and use its own userName +// फ़ंक्शन अपना स्वयं का userName बनाएगा और उसका उपयोग करेगा showMessage(); -alert( userName ); // *!*John*/!*, unchanged, the function did not access the outer variable +alert( userName ); // *!*John*/!*, अपरिवर्तित, function बाहरी variable का उपयोग नहीं करता है ``` ```smart header="Global variables" -Variables declared outside of any function, such as the outer `userName` in the code above, are called *global*. +किसी function के बाहर घोषित variables, जैसे उपरोक्त कोड में बाहरी `userName`, *global* कहलाते हैं। -Global variables are visible from any function (unless shadowed by locals). +ग्लोबल variables किसी भी function से दिखाई देते हैं (जब तक कि लोकल द्वारा छिपा न हो)। -It's a good practice to minimize the use of global variables. Modern code has few or no globals. Most variables reside in their functions. Sometimes though, they can be useful to store project-level data. +ग्लोबल variable के उपयोग को कम करने के लिए यह एक अच्छा अभ्यास है। आधुनिक कोड में कुछ या कोई ग्लोबल्स नहीं हैं। अधिकांश variable अपने functions में रहते हैं। हालांकि कभी-कभी, वे प्रोजेक्ट-स्तरीय डेटा संग्रहीत करने के लिए उपयोगी हो सकते हैं। ``` ## Parameters -We can pass arbitrary data to functions using parameters (also called *function arguments*) . +हम Parameters (जिसे _function arguments_ भी कहा जाता है) का उपयोग करके function को मनमाना डेटा पास कर सकते हैं। -In the example below, the function has two parameters: `from` and `text`. +नीचे दिए गए उदाहरण में, function के दो parameters हैं: `from` और `text`। ```js run function showMessage(*!*from, text*/!*) { // arguments: from, text @@ -152,10 +158,9 @@ showMessage('Ann', "What's up?"); // Ann: What's up? (**) */!* ``` -When the function is called in lines `(*)` and `(**)`, the given values are copied to local variables `from` and `text`. Then the function uses them. - -Here's one more example: we have a variable `from` and pass it to the function. Please note: the function changes `from`, but the change is not seen outside, because a function always gets a copy of the value: +जब function को लाइनों में कॉल किया जाता है `(*)` और `(**)`, तो दिए गए मानों को लोकल variables में कॉपी किया जाता है `from` और `text`। फिर function उनका उपयोग करता है। +यहां एक और उदाहरण दिया गया है: हमारे पास एक variable `from` है और इसे function में पास करें। कृपया ध्यान दें: function `from` को बदलता है, लेकिन परिवर्तन बाहर नहीं देखा जाता है, क्योंकि function को हमेशा मूल्य की एक प्रति प्राप्त होती है: ```js run function showMessage(from, text) { @@ -177,17 +182,19 @@ alert( from ); // Ann ## Default values -If a parameter is not provided, then its value becomes `undefined`. +## डिफॉल्ट वैल्यूज + +यदि कोई parameter प्रदान नहीं किया जाता है, तो उसका मान `undefined` हो जाता है। -For instance, the aforementioned function `showMessage(from, text)` can be called with a single argument: +उदाहरण के लिए, उपरोक्त function `showMessage(from, text)` को एक argument के साथ बुलाया जा सकता है: ```js showMessage("Ann"); ``` -That's not an error. Such a call would output `"*Ann*: undefined"`. There's no `text`, so it's assumed that `text === undefined`. +यह कोई एरर नहीं है। ऐसी कॉल `"*Ann*: undefined"` आउटपुट करेगी। कोई `text` नहीं है, इसलिए यह माना जाता है कि `text === undefined`। -If we want to use a "default" `text` in this case, then we can specify it after `=`: +यदि हम इस मामले में "डिफ़ॉल्ट" `text` का उपयोग करना चाहते हैं, तो हम इसे `=` के बाद उल्लिखत कर सकते हैं: ```js run function showMessage(from, *!*text = "no text given"*/!*) { @@ -197,9 +204,9 @@ function showMessage(from, *!*text = "no text given"*/!*) { showMessage("Ann"); // Ann: no text given ``` -Now if the `text` parameter is not passed, it will get the value `"no text given"` +अब यदि `text` parameter नहीं देना गया हो, तो उसे `"no text given"` मान मिलेगा। -Here `"no text given"` is a string, but it can be a more complex expression, which is only evaluated and assigned if the parameter is missing. So, this is also possible: +यहां `"no text given"` एक स्ट्रिंग है, लेकिन यह एक अधिक जटिल अभिव्यक्ति हो सकती है, जिसका केवल मूल्यांकन किया जाता है और parameter गायब होने पर असाइन किया जाता है। तो, यह भी संभव है: ```js run function showMessage(from, text = anotherFunction()) { @@ -209,45 +216,47 @@ function showMessage(from, text = anotherFunction()) { ``` ```smart header="Evaluation of default parameters" -In JavaScript, a default parameter is evaluated every time the function is called without the respective parameter. +जावास्क्रिप्ट में, हर बार संबंधित parameter के बिना function को कॉल किए जाने पर एक डिफ़ॉल्ट parameter का मूल्यांकन किया जाता है। -In the example above, `anotherFunction()` is called every time `showMessage()` is called without the `text` parameter. +ऊपर दिए गए उदाहरण में, `anotherFunction()` को हर बार `showMessage()` को `text` parameter के बिना कहा जाता है। ``` ### Alternative default parameters -Sometimes it makes sense to set default values for parameters not in the function declaration, but at a later stage, during its execution. +### वैकल्पिक डिफ़ॉल्ट parameters -To check for an omitted parameter, we can compare it with `undefined`: +कभी-कभी function घोषणा में parameter के लिए डिफ़ॉल्ट मान सेट करना समझ में आता है, लेकिन बाद के चरण में, इसके निष्पादन के दौरान भी सेट किया जाता है। + +छोड़े गए पैरामीटर की जांच करने के लिए, हम इसकी तुलना `undefined` से कर सकते हैं: ```js run function showMessage(text) { *!* if (text === undefined) { - text = 'empty message'; + text = 'खाली संदेश'; } */!* alert(text); } -showMessage(); // empty message +showMessage(); // खाली संदेश ``` -...Or we could use the `||` operator: +...या हम `||` ऑपरेटर का उपयोग कर सकते हैं: ```js -// if text parameter is omitted or "" is passed, set it to 'empty' +// यदि टेक्स्ट पैरामीटर छोड़ा गया है या "" पारित किया गया है, तो इसे 'खाली' पर सेट करें function showMessage(text) { text = text || 'empty'; ... } ``` -Modern JavaScript engines support the [nullish coalescing operator](info:nullish-coalescing-operator) `??`, it's better when falsy values, such as `0`, are considered regular: +आधुनिक जावास्क्रिप्ट इंजन [nullish coalescing operator](info:nullish-coalescing-operator) `??` को सपोर्ट करती है| यह तब बेहतर होता है जब `0` जैसे झूठे मूल्यों को नियमित माना जाता है: ```js run -// if there's no "count" parameter, show "unknown" +// यदि कोई "count" पैरामीटर नहीं है, तो "unknown" दिखाएं function showCount(count) { alert(count ?? "unknown"); } @@ -259,9 +268,11 @@ showCount(); // unknown ## Returning a value -A function can return a value back into the calling code as the result. +## एक मान लौटाना + +एक function परिणाम के रूप में एक मान वापस कॉलिंग कोड में वापस कर सकता है। -The simplest example would be a function that sums two values: +सबसे सरल उदाहरण एक ऐसा function होगा जो दो मानों का योग करता है: ```js run no-beautify function sum(a, b) { @@ -272,9 +283,9 @@ let result = sum(1, 2); alert( result ); // 3 ``` -The directive `return` can be in any place of the function. When the execution reaches it, the function stops, and the value is returned to the calling code (assigned to `result` above). +निर्देश `return` function के किसी भी स्थान पर हो सकता है। जब निष्पादन उस तक पहुंच जाता है, तो function बंद हो जाता है, और मान कॉलिंग कोड पर वापस आ जाता है (उपरोक्त `result` को सौंपा गया) -There may be many occurrences of `return` in a single function. For instance: +एक function में `return` की कई घटनाएं हो सकती हैं। उदाहरण के लिए: ```js run function checkAge(age) { @@ -284,23 +295,23 @@ function checkAge(age) { */!* } else { *!* - return confirm('Do you have permission from your parents?'); + return confirm('क्या आपके पास अपने माता-पिता से अनुमति है?'); */!* } } -let age = prompt('How old are you?', 18); +let age = prompt('आपकी उम्र क्या है?', 18); if ( checkAge(age) ) { - alert( 'Access granted' ); + alert( 'प्रवेश करने की अनुमति है' ); } else { - alert( 'Access denied' ); + alert( 'पहुंच अस्वीकृत' ); } ``` -It is possible to use `return` without a value. That causes the function to exit immediately. +बिना मूल्य के `return` का उपयोग करना संभव है। यह function को तुरंत बाहर निकलने का कारण बनता है। -For example: +उदाहरण के लिए: ```js function showMovie(age) { @@ -310,50 +321,52 @@ function showMovie(age) { */!* } - alert( "Showing you the movie" ); // (*) + alert( "आपको फिल्म दिखा रहा है" ); // (*) // ... } ``` -In the code above, if `checkAge(age)` returns `false`, then `showMovie` won't proceed to the `alert`. +ऊपर दिए गए कोड में, अगर ` checkAge(age)` `false` लौटाता है, तो `showMovie` `alert` पर आगे नहीं बढ़ेगा। -````smart header="A function with an empty `return` or without it returns `undefined`" -If a function does not return a value, it is the same as if it returns `undefined`: +````smart header="A function with an empty `return`or without it returns`undefined`" If a function does not return a value, it is the same as if it returns `undefined`: ```js run -function doNothing() { /* empty */ } +function doNothing() { + /* खाली */ +} -alert( doNothing() === undefined ); // true +alert(doNothing() === undefined); // सच ``` -An empty `return` is also the same as `return undefined`: +एक खाली `return` भी `return undefined` जैसा ही है: ```js run function doNothing() { return; } -alert( doNothing() === undefined ); // true +alert(doNothing() === undefined); // सच ``` -```` + +````` ````warn header="Never add a newline between `return` and the value" -For a long expression in `return`, it might be tempting to put it on a separate line, like this: +`return` में एक लंबी अभिव्यक्ति के लिए, इसे एक अलग लाइन पर रखना आकर्षक हो सकता है, जैसे: ```js return (some + long + expression + or + whatever * f(a) + f(b)) ``` -That doesn't work, because JavaScript assumes a semicolon after `return`. That'll work the same as: +यह काम नहीं करता है, क्योंकि `return` के बाद जावास्क्रिप्ट सेमीकोलन लगा देता है । यह उसी तरह काम करेगा: ```js return*!*;*/!* (some + long + expression + or + whatever * f(a) + f(b)) ``` -So, it effectively becomes an empty return. +तो, यह प्रभावी रूप से एक खाली रिटर्न बन जाता है। -If we want the returned expression to wrap across multiple lines, we should start it at the same line as `return`. Or at least put the opening parentheses there as follows: +यदि हम चाहते हैं कि लौटाए गए एक्सप्रेशन को कई लाइनों में लपेटा जाए, तो हमें इसे उसी लाइन से शुरू करना चाहिए जैसे `return`। या कम से कम उद्घाटन कोष्ठक इस प्रकार रखें: ```js return ( @@ -362,82 +375,81 @@ return ( whatever * f(a) + f(b) ) ``` -And it will work just as we expect it to. -```` +और यह वैसे ही काम करेगा जैसा हम उम्मीद करते हैं। +````` -## Naming a function [#function-naming] +## एक function का नामकरण [#function-naming] -Functions are actions. So their name is usually a verb. It should be brief, as accurate as possible and describe what the function does, so that someone reading the code gets an indication of what the function does. +Functions क्रिया हैं। तो उनका नाम आमतौर पर एक क्रिया है। यह संक्षिप्त होना चाहिए, यथासंभव सटीक होना चाहिए और यह वर्णन करना चाहिए कि function क्या करता है, ताकि कोड पढ़ने वाले व्यक्ति को यह संकेत मिल सके कि function क्या करता है। -It is a widespread practice to start a function with a verbal prefix which vaguely describes the action. There must be an agreement within the team on the meaning of the prefixes. +क्रिया को अस्पष्ट रूप से वर्णित करने वाले मौखिक उपसर्ग के साथ function प्रारंभ करना एक व्यापक प्रथा है। उपसर्गों के अर्थ पर टीम के भीतर एक समझौता होना चाहिए। -For instance, functions that start with `"show"` usually show something. +उदाहरण के लिए, `"show"` से शुरू होने वाले फ़ंक्शन आमतौर पर कुछ दिखाते हैं। -Function starting with... +Function की शुरुआत... -- `"get…"` -- return a value, -- `"calc…"` -- calculate something, -- `"create…"` -- create something, -- `"check…"` -- check something and return a boolean, etc. +- `"get…"` -- एक मूल्य वापस करें, +- `"calc…"` -- कुछ गणना करो, +- `"create…"` -- कुछ बनाये, +- `"check…"` -- कुछ जांचें और एक बूलियन लौटाएं, आदि। -Examples of such names: +ऐसे नामों के उदाहरण: ```js no-beautify -showMessage(..) // shows a message -getAge(..) // returns the age (gets it somehow) -calcSum(..) // calculates a sum and returns the result -createForm(..) // creates a form (and usually returns it) -checkPermission(..) // checks a permission, returns true/false +showMessage(..) // एक संदेश दिखाता है +getAge(..) // उम्र लौटाता है (इसे किसी तरह प्राप्त करता है) +calcSum(..) // एक योग की गणना करता है और परिणाम देता है +createForm(..) // एक फॉर्म बनाता है (और आमतौर पर इसे वापस करता है) +checkPermission(..) // अनुमति की जाँच करता है, सही/गलत लौटाता है ``` -With prefixes in place, a glance at a function name gives an understanding what kind of work it does and what kind of value it returns. +उपसर्गों के साथ, function नाम पर एक नज़र यह समझ देती है कि यह किस प्रकार का कार्य करता है और यह किस प्रकार का मूल्य देता है। ```smart header="One function -- one action" -A function should do exactly what is suggested by its name, no more. +एक function को ठीक वही करना चाहिए जो उसके नाम से सुझाया गया है, और नहीं। -Two independent actions usually deserve two functions, even if they are usually called together (in that case we can make a 3rd function that calls those two). +दो स्वतंत्र क्रियाएं आम तौर पर दो functions की सेवा करती हैं, भले ही उन्हें आम तौर पर एक साथ बुलाया जाता है (उस स्थिति में हम एक तीसरा function बना सकते हैं जो उन दोनों को कॉल करता है)। -A few examples of breaking this rule: +इस नियम को तोड़ने के कुछ उदाहरण: -- `getAge` -- would be bad if it shows an `alert` with the age (should only get). -- `createForm` -- would be bad if it modifies the document, adding a form to it (should only create it and return). -- `checkPermission` -- would be bad if it displays the `access granted/denied` message (should only perform the check and return the result). +- `getAge` -- बुरा होगा अगर यह उम्र के साथ एक `alert` दिखाता है (सिर्फ लेना चाहिए )। +- `createForm` -- खराब होगा यदि यह डॉक्यूमेंट को संशोधित करता है, इसमें एक फॉर्म जोड़ता है (केवल इसे बनाना और वापस करना चाहिए)। +- `checkPermission` -- खराब होगा यदि यह `access granted/denied` संदेश प्रदर्शित करता है (केवल जांच करना चाहिए और परिणाम वापस करना चाहिए)। -These examples assume common meanings of prefixes. You and your team are free to agree on other meanings, but usually they're not much different. In any case, you should have a firm understanding of what a prefix means, what a prefixed function can and cannot do. All same-prefixed functions should obey the rules. And the team should share the knowledge. +ये उदाहरण उपसर्गों के सामान्य अर्थ ग्रहण करते हैं। आप और आपकी टीम अन्य अर्थों पर सहमत होने के लिए स्वतंत्र हैं, लेकिन आमतौर पर, वे बहुत भिन्न नहीं होते हैं। किसी भी मामले में, आपको इस बात की पक्की समझ होनी चाहिए कि उपसर्ग का क्या अर्थ है, उपसर्ग का function क्या कर सकता है और क्या नहीं। सभी समान-उपसर्ग फ़ंक्शन को नियमों का पालन करना चाहिए। और टीम को ज्ञान साझा करना चाहिए। ``` ```smart header="Ultrashort function names" -Functions that are used *very often* sometimes have ultrashort names. +*अक्सर* उपयोग किए जाने वाले फ़ंक्शंस में कभी-कभी अल्ट्रा-शॉर्ट नाम होते हैं। -For example, the [jQuery](http://jquery.com) framework defines a function with `$`. The [Lodash](http://lodash.com/) library has its core function named `_`. +उदाहरण के लिए, [jQuery](http://jquery.com) फ्रेमवर्क `$` के साथ एक function को परिभाषित करता है। The [Lodash](http://lodash.com/) library का मुख्य function `_` है। -These are exceptions. Generally functions names should be concise and descriptive. +ये अपवाद हैं। आम तौर पर functions नाम संक्षिप्त और वर्णनात्मक होने चाहिए। ``` ## Functions == Comments -Functions should be short and do exactly one thing. If that thing is big, maybe it's worth it to split the function into a few smaller functions. Sometimes following this rule may not be that easy, but it's definitely a good thing. +Functions छोटे होने चाहिए और ठीक एक काम करना चाहिए। अगर वह चीज बड़ी है, तो शायद यह function को कुछ छोटे functions में विभाजित करना बेहतर है। कभी-कभी इस नियम का पालन करना इतना आसान नहीं हो सकता है, लेकिन यह निश्चित रूप से एक अच्छी बात है। -A separate function is not only easier to test and debug -- its very existence is a great comment! +एक अलग function न केवल परीक्षण और डीबग करना आसान है - इसका अस्तित्व एक महान comment है! -For instance, compare the two functions `showPrimes(n)` below. Each one outputs [prime numbers](https://en.wikipedia.org/wiki/Prime_number) up to `n`. +उदाहरण के लिए, नीचे दिए गए दो कार्यों `showPrimes(n)` की तुलना करें। हर एक `n` तक [अभाज्य संख्याएँ](https://en.wikipedia.org/wiki/Prime_number) आउटपुट करता है। -The first variant uses a label: +पहला संस्करण एक लेबल का उपयोग करता है: ```js function showPrimes(n) { nextPrime: for (let i = 2; i < n; i++) { - for (let j = 2; j < i; j++) { if (i % j == 0) continue nextPrime; } - alert( i ); // a prime + alert(i); // एक अभाज्य संख्या } } ``` -The second variant uses an additional function `isPrime(n)` to test for primality: +दूसरा संस्करण अभाज्यता के परीक्षण के लिए एक अतिरिक्त function `isPrime(n)` का उपयोग करता है: ```js function showPrimes(n) { @@ -445,7 +457,7 @@ function showPrimes(n) { for (let i = 2; i < n; i++) { *!*if (!isPrime(i)) continue;*/!* - alert(i); // a prime + alert(i); // एक अभाज्य संख्या } } @@ -457,13 +469,13 @@ function isPrime(n) { } ``` -The second variant is easier to understand, isn't it? Instead of the code piece we see a name of the action (`isPrime`). Sometimes people refer to such code as *self-describing*. +दूसरा संस्करण समझना आसान है, है ना? कोड पीस के बजाय हम क्रिया का एक नाम देखते हैं (`isPrime`)। कभी-कभी लोग ऐसे कोड को _self-describing_ कहते हैं। -So, functions can be created even if we don't intend to reuse them. They structure the code and make it readable. +इसलिए, function बनाए जा सकते हैं, भले ही हम उनका पुन: उपयोग करने का इरादा न रखते हों। वे कोड की संरचना करते हैं और इसे पठनीय बनाते हैं। -## Summary +## सारांश -A function declaration looks like this: +एक function घोषणा इस तरह दिखती है: ```js function name(parameters, delimited, by, comma) { @@ -471,18 +483,18 @@ function name(parameters, delimited, by, comma) { } ``` -- Values passed to a function as parameters are copied to its local variables. -- A function may access outer variables. But it works only from inside out. The code outside of the function doesn't see its local variables. -- A function can return a value. If it doesn't, then its result is `undefined`. +- किसी function को दिए गए मान parameters के रूप में उसके local variables में कॉपी किए जाते हैं। +- एक function बाहरी variables का इस्तेमाल कर सकता है। लेकिन यह केवल अंदर से बाहर काम करता है। function के बाहर का कोड इसके स्थानीय variables नहीं देखता है। +- एक function एक मान वापस कर सकता है। यदि ऐसा नहीं होता है, तो इसका परिणाम `undefined` होता है। -To make the code clean and easy to understand, it's recommended to use mainly local variables and parameters in the function, not outer variables. +कोड को साफ और समझने में आसान बनाने के लिए, function में मुख्य रूप से local variables और parameter का उपयोग करने की अनुशंसा की जाती है, outer variables नहीं। -It is always easier to understand a function which gets parameters, works with them and returns a result than a function which gets no parameters, but modifies outer variables as a side-effect. +ऐसे function को समझना हमेशा आसान होता है जो पैरामीटर प्राप्त करता है, उनके साथ काम करता है, और किसी ऐसे फ़ंक्शन की तुलना में परिणाम देता है जिसमें कोई पैरामीटर नहीं होता है, लेकिन बाहरी variables को साइड-इफेक्ट के रूप में संशोधित करता है। -Function naming: +Function नामकरण: -- A name should clearly describe what the function does. When we see a function call in the code, a good name instantly gives us an understanding what it does and returns. -- A function is an action, so function names are usually verbal. -- There exist many well-known function prefixes like `create…`, `show…`, `get…`, `check…` and so on. Use them to hint what a function does. +- एक नाम स्पष्ट रूप से वर्णन करना चाहिए कि function क्या करता है। जब हम कोड में एक function कॉल देखते हैं, तो एक अच्छा नाम हमें तुरंत समझा देता है कि यह क्या करता है और क्या वापस लौटता है। +- एक function एक क्रिया है, इसलिए function नाम आमतौर पर मौखिक होते हैं। +- कई प्रसिद्ध function प्रीफ़िक्स मौजूद हैं जैसे `create…`, `show…`, `get…`, `check…` और इसी तरह। function क्या करता है यह संकेत देने के लिए उनका उपयोग करें। -Functions are the main building blocks of scripts. Now we've covered the basics, so we actually can start creating and using them. But that's only the beginning of the path. We are going to return to them many times, going more deeply into their advanced features. +Function स्क्रिप्ट के मुख्य निर्माण खंड हैं। अब हमने मूल बातें शामिल कर ली हैं, इसलिए हम वास्तव में उन्हें बनाना और उनका उपयोग करना शुरू कर सकते हैं। लेकिन यह सिर्फ रास्ते की शुरुआत है। हम कई बार उनके पास वापस जायेंगे, उन्नत सुविधाओं में और अधिक गहराई से इनको जानेंगे। From b6328927088d6e23fe7b6048d24952c51df9024a Mon Sep 17 00:00:00 2001 From: rskhan167 Date: Fri, 10 Sep 2021 00:44:08 +0530 Subject: [PATCH 09/36] fix translate --- .../1-if-else-required/solution.md | 1 - .../1-if-else-required/task.md | 14 ++++---------- .../2-rewrite-function-question-or/solution.md | 7 ++----- .../2-rewrite-function-question-or/task.md | 16 ++++------------ .../15-function-basics/3-min/solution.md | 3 --- .../15-function-basics/3-min/task.md | 12 ++++-------- 6 files changed, 14 insertions(+), 39 deletions(-) diff --git a/1-js/02-first-steps/15-function-basics/1-if-else-required/solution.md b/1-js/02-first-steps/15-function-basics/1-if-else-required/solution.md index bb54ffb54..7e1a36a09 100644 --- a/1-js/02-first-steps/15-function-basics/1-if-else-required/solution.md +++ b/1-js/02-first-steps/15-function-basics/1-if-else-required/solution.md @@ -1,2 +1 @@ -No difference. कोई फर्क नहीं। diff --git a/1-js/02-first-steps/15-function-basics/1-if-else-required/task.md b/1-js/02-first-steps/15-function-basics/1-if-else-required/task.md index c1d83124c..3678b4034 100644 --- a/1-js/02-first-steps/15-function-basics/1-if-else-required/task.md +++ b/1-js/02-first-steps/15-function-basics/1-if-else-required/task.md @@ -2,14 +2,10 @@ importance: 4 --- -# Is "else" required? - # क्या "else" आवश्यक है? -The following function returns `true` if the parameter `age` is greater than `18`. -यदि `age` पैरामीटर `18` से अधिक है, तो निम्नलिखित फ़ंक्शन `true` लौटाता है। +यदि `age` parameter `18` से अधिक है, तो निम्नलिखित function `true` लौटाता है। -Otherwise it asks for a confirmation and returns its result: अन्यथा, यह एक पुष्टिकरण मांगता है और अपना परिणाम देता है: ```js @@ -19,14 +15,13 @@ function checkAge(age) { *!* } else { // ... - return confirm('Did parents allow you?'); + return confirm('क्या माता-पिता ने आपको अनुमति दी थी?'); } */!* } ``` -Will the function work differently if `else` is removed? -यदि `else` हटा दिया जाता है तो क्या फ़ंक्शन अलग तरह से काम करेगा? +यदि `else` हटा दिया जाता है तो क्या function अलग तरह से काम करेगा? ```js function checkAge(age) { @@ -35,10 +30,9 @@ function checkAge(age) { } *!* // ... - return confirm('Did parents allow you?'); + return confirm('क्या माता-पिता ने आपको अनुमति दी थी?'); */!* } ``` -Is there any difference in the behavior of these two variants? क्या इन दोनों रूपों के व्यवहार में कोई अंतर है? diff --git a/1-js/02-first-steps/15-function-basics/2-rewrite-function-question-or/solution.md b/1-js/02-first-steps/15-function-basics/2-rewrite-function-question-or/solution.md index f73af505b..f4caab6bb 100644 --- a/1-js/02-first-steps/15-function-basics/2-rewrite-function-question-or/solution.md +++ b/1-js/02-first-steps/15-function-basics/2-rewrite-function-question-or/solution.md @@ -1,20 +1,17 @@ -Using a question mark operator `'?'`: प्रश्न चिह्न ऑपरेटर का उपयोग करते हुए `?`: ```js function checkAge(age) { - return (age > 18) ? true : confirm('Did parents allow you?'); + return age > 18 ? true : confirm("Did parents allow you?"); } ``` -Using OR `||` (the shortest variant): OR ऑपरेटर का उपयोग करते हुए `||` (सबसे छोटा संस्करण) ```js function checkAge(age) { - return (age > 18) || confirm('Did parents allow you?'); + return age > 18 || confirm("Did parents allow you?"); } ``` -Note that the parentheses around `age > 18` are not required here. They exist for better readabiltiy. ध्यान दें कि यहां `age > 18` के आसपास के कोष्ठकों की आवश्यकता नहीं है। वे बेहतर पठनीयता के लिए मौजूद हैं। diff --git a/1-js/02-first-steps/15-function-basics/2-rewrite-function-question-or/task.md b/1-js/02-first-steps/15-function-basics/2-rewrite-function-question-or/task.md index bd204330c..0be0d9ccb 100644 --- a/1-js/02-first-steps/15-function-basics/2-rewrite-function-question-or/task.md +++ b/1-js/02-first-steps/15-function-basics/2-rewrite-function-question-or/task.md @@ -2,14 +2,10 @@ importance: 4 --- -# Rewrite the function using '?' or '||' +# '?' या '||' का उपयोग करके function को फिर से लिखें| -# '?' या '||' का उपयोग करके फ़ंक्शन को फिर से लिखें| +यदि `age` parameter `18` से अधिक है, तो निम्नलिखित function `true` लौटाता है। -The following function returns `true` if the parameter `age` is greater than `18`. -यदि `age` पैरामीटर `18` से अधिक है, तो निम्नलिखित फ़ंक्शन `true` लौटाता है। - -Otherwise it asks for a confirmation and returns its result. अन्यथा, यह एक पुष्टिकरण मांगता है और अपना परिणाम देता है: ```js @@ -17,18 +13,14 @@ function checkAge(age) { if (age > 18) { return true; } else { - return confirm('Did parents allow you?'); + return confirm("क्या माता-पिता ने आपको अनुमति दी थी?"); } } ``` -Rewrite it, to perform the same, but without `if`, in a single line. इसे फिर से लिखें, वही प्रदर्शन करने के लिए, लेकिन बिना `if` के, एक पंक्ति में। -Make two variants of `checkAge`: -'checkAge' के दो प्रकार बनाएं: +`checkAge` के दो प्रकार बनाएं: -1. Using a question mark operator `?` -2. Using OR `||` 1. प्रश्न चिह्न ऑपरेटर का उपयोग करते हुए `?` 2. OR ऑपरेटर का उपयोग करते हुए `||` diff --git a/1-js/02-first-steps/15-function-basics/3-min/solution.md b/1-js/02-first-steps/15-function-basics/3-min/solution.md index f46c297bb..e3f1c0d47 100644 --- a/1-js/02-first-steps/15-function-basics/3-min/solution.md +++ b/1-js/02-first-steps/15-function-basics/3-min/solution.md @@ -1,4 +1,3 @@ -A solution using `if`: `if` का उपयोग करके एक हल: ```js @@ -11,7 +10,6 @@ function min(a, b) { } ``` -A solution with a question mark operator `'?'`: प्रश्न चिह्न ऑपरेटर `'?'` के साथ एक हल: ```js @@ -20,5 +18,4 @@ function min(a, b) { } ``` -P.S. In the case of an equality `a == b` it does not matter what to return. नोट: समानता `a == b` के मामले में यह मायने नहीं रखता कि क्या लौटाया जाए। diff --git a/1-js/02-first-steps/15-function-basics/3-min/task.md b/1-js/02-first-steps/15-function-basics/3-min/task.md index b6910a40d..1b30f832c 100644 --- a/1-js/02-first-steps/15-function-basics/3-min/task.md +++ b/1-js/02-first-steps/15-function-basics/3-min/task.md @@ -4,16 +4,12 @@ importance: 1 # Function min(a, b) -# फंक्शन min(a, b) +एक function लिखें `min(a,b)` जो कम से कम दो नंबर `a` और `b` लौटाता है। -Write a function `min(a,b)` which returns the least of two numbers `a` and `b`. -एक फ़ंक्शन लिखें `min(a,b)` जो कम से कम दो नंबर `a` और `b` लौटाता है। - -For instance: उदाहरण के लिए: ```js -min(2, 5) == 2 -min(3, -1) == -1 -min(1, 1) == 1 +min(2, 5) == 2; +min(3, -1) == -1; +min(1, 1) == 1; ``` From 1d427532658866ba136a10fb5033c2dd3e5147db Mon Sep 17 00:00:00 2001 From: Rasool Khan <35368463+rskhan167@users.noreply.github.com> Date: Fri, 10 Sep 2021 00:47:24 +0530 Subject: [PATCH 10/36] fix IDE's autochanges --- .../2-rewrite-function-question-or/solution.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/1-js/02-first-steps/15-function-basics/2-rewrite-function-question-or/solution.md b/1-js/02-first-steps/15-function-basics/2-rewrite-function-question-or/solution.md index f4caab6bb..c212e65b0 100644 --- a/1-js/02-first-steps/15-function-basics/2-rewrite-function-question-or/solution.md +++ b/1-js/02-first-steps/15-function-basics/2-rewrite-function-question-or/solution.md @@ -2,7 +2,7 @@ ```js function checkAge(age) { - return age > 18 ? true : confirm("Did parents allow you?"); + return (age > 18) ? true : confirm('क्या माता-पिता ने आपको अनुमति दी थी?'); } ``` @@ -10,7 +10,7 @@ OR ऑपरेटर का उपयोग करते हुए `||` (सब ```js function checkAge(age) { - return age > 18 || confirm("Did parents allow you?"); + return (age > 18) || confirm('क्या माता-पिता ने आपको अनुमति दी थ?'); } ``` From 93aa7be037f7f182ba887b14760adcf28c1e3fdc Mon Sep 17 00:00:00 2001 From: Rasool Khan <35368463+rskhan167@users.noreply.github.com> Date: Fri, 10 Sep 2021 00:52:03 +0530 Subject: [PATCH 11/36] fix IDE's autochanges --- 1-js/02-first-steps/15-function-basics/article.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/1-js/02-first-steps/15-function-basics/article.md b/1-js/02-first-steps/15-function-basics/article.md index 1c635dd49..8fa8a9aec 100644 --- a/1-js/02-first-steps/15-function-basics/article.md +++ b/1-js/02-first-steps/15-function-basics/article.md @@ -18,7 +18,7 @@ function बनाने के लिए हम एक _function declaration_ ```js function showMessage() { - alert("सभी को नमस्कार!"); + alert( "सभी को नमस्कार!" ); } ``` @@ -335,7 +335,7 @@ function doNothing() { /* खाली */ } -alert(doNothing() === undefined); // सच +alert( doNothing() === undefined ); // सच ``` एक खाली `return` भी `return undefined` जैसा ही है: @@ -345,7 +345,7 @@ function doNothing() { return; } -alert(doNothing() === undefined); // सच +alert( doNothing() === undefined ); // सच ``` ````` @@ -376,7 +376,7 @@ return ( ) ``` और यह वैसे ही काम करेगा जैसा हम उम्मीद करते हैं। -````` +```` ## एक function का नामकरण [#function-naming] @@ -444,7 +444,7 @@ function showPrimes(n) { if (i % j == 0) continue nextPrime; } - alert(i); // एक अभाज्य संख्या + alert( i ); // एक अभाज्य संख्या } } ``` From f39ab2bb3308b2240fa3c574e17bf2aaa3e7dcac Mon Sep 17 00:00:00 2001 From: Rasool Khan <35368463+rskhan167@users.noreply.github.com> Date: Fri, 10 Sep 2021 00:55:09 +0530 Subject: [PATCH 12/36] fix IDE's autochanges --- 1-js/02-first-steps/15-function-basics/3-min/task.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/1-js/02-first-steps/15-function-basics/3-min/task.md b/1-js/02-first-steps/15-function-basics/3-min/task.md index 1b30f832c..397953d8b 100644 --- a/1-js/02-first-steps/15-function-basics/3-min/task.md +++ b/1-js/02-first-steps/15-function-basics/3-min/task.md @@ -9,7 +9,7 @@ importance: 1 उदाहरण के लिए: ```js -min(2, 5) == 2; -min(3, -1) == -1; -min(1, 1) == 1; +min(2, 5) == 2 +min(3, -1) == -1 +min(1, 1) == 1 ``` From 5bf0d16798ec15067cc5afc91e8a0c3d533d3fa4 Mon Sep 17 00:00:00 2001 From: Rasool Khan <35368463+rskhan167@users.noreply.github.com> Date: Tue, 14 Sep 2021 14:33:25 +0530 Subject: [PATCH 13/36] fix some translations --- 1-js/02-first-steps/15-function-basics/article.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/1-js/02-first-steps/15-function-basics/article.md b/1-js/02-first-steps/15-function-basics/article.md index 8fa8a9aec..24a98af17 100644 --- a/1-js/02-first-steps/15-function-basics/article.md +++ b/1-js/02-first-steps/15-function-basics/article.md @@ -335,7 +335,7 @@ function doNothing() { /* खाली */ } -alert( doNothing() === undefined ); // सच +alert( doNothing() === undefined ); // true ``` एक खाली `return` भी `return undefined` जैसा ही है: @@ -345,7 +345,7 @@ function doNothing() { return; } -alert( doNothing() === undefined ); // सच +alert( doNothing() === undefined ); // true ``` ````` From badd33b4039cd98c6b51e2d5713f443742b571c5 Mon Sep 17 00:00:00 2001 From: Rasool Khan <35368463+rskhan167@users.noreply.github.com> Date: Tue, 21 Sep 2021 09:30:10 +0530 Subject: [PATCH 14/36] Update task.md --- 1-js/02-first-steps/15-function-basics/3-min/task.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/15-function-basics/3-min/task.md b/1-js/02-first-steps/15-function-basics/3-min/task.md index 397953d8b..27a40df27 100644 --- a/1-js/02-first-steps/15-function-basics/3-min/task.md +++ b/1-js/02-first-steps/15-function-basics/3-min/task.md @@ -4,7 +4,7 @@ importance: 1 # Function min(a, b) -एक function लिखें `min(a,b)` जो कम से कम दो नंबर `a` और `b` लौटाता है। +एक फ़ंक्शन लिखें `min(a,b)` जो `a` और `b` नंबर में सबसे छोटा है उसको लौटाता है। उदाहरण के लिए: From 1eac2810eb474c0403cfd39d16d038a00c404ef0 Mon Sep 17 00:00:00 2001 From: Rasool Khan <35368463+rskhan167@users.noreply.github.com> Date: Tue, 21 Sep 2021 09:38:04 +0530 Subject: [PATCH 15/36] Update task.md --- 1-js/02-first-steps/15-function-basics/4-pow/task.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/15-function-basics/4-pow/task.md b/1-js/02-first-steps/15-function-basics/4-pow/task.md index 26b090f09..931fd96b1 100644 --- a/1-js/02-first-steps/15-function-basics/4-pow/task.md +++ b/1-js/02-first-steps/15-function-basics/4-pow/task.md @@ -4,7 +4,7 @@ importance: 4 # Function pow(x,n) -एक function लिखें `pow(x,n)` जो `x` को `n` के शक्ति में लौटाता है। या, दूसरे शब्दों में, `x` को अपने आप से `n` गुणा से गुणा करता है और परिणाम देता है। +एक फ़ंक्शन लिखें `pow(x,n)` जो `x` को `n` की घात में लौटाता है। या, दूसरे शब्दों में, `x` को अपने आप से `n` बार गुणा करता है और परिणाम देता है। ```js pow(3, 2) = 3 * 3 = 9 From de48b642651ad29c8b111fb97569bb2b7b6d5544 Mon Sep 17 00:00:00 2001 From: Rasool Khan <35368463+rskhan167@users.noreply.github.com> Date: Tue, 21 Sep 2021 09:42:59 +0530 Subject: [PATCH 16/36] Update task.md --- 1-js/02-first-steps/15-function-basics/4-pow/task.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/15-function-basics/4-pow/task.md b/1-js/02-first-steps/15-function-basics/4-pow/task.md index 931fd96b1..097f9cf8a 100644 --- a/1-js/02-first-steps/15-function-basics/4-pow/task.md +++ b/1-js/02-first-steps/15-function-basics/4-pow/task.md @@ -16,4 +16,4 @@ pow(1, 100) = 1 * 1 * ...* 1 = 1 [demo] -नोट: इस टास्क में function को केवल `n` के प्राकृतिक मान का समर्थन करना चाहिए: `1` से ऊपर के पूर्णांक। +नोट: इस टास्क में फ़ंक्शन को केवल `n` के प्राकृतिक मानों को स्वीकार करना चाहिए: `1` से ऊपर के पूर्णांक। From dc463a3f02676c7038644921e913d9e9d5b102cc Mon Sep 17 00:00:00 2001 From: Rasool Khan <35368463+rskhan167@users.noreply.github.com> Date: Tue, 21 Sep 2021 09:56:41 +0530 Subject: [PATCH 17/36] Update article.md --- 1-js/02-first-steps/15-function-basics/article.md | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/1-js/02-first-steps/15-function-basics/article.md b/1-js/02-first-steps/15-function-basics/article.md index 24a98af17..a9c130618 100644 --- a/1-js/02-first-steps/15-function-basics/article.md +++ b/1-js/02-first-steps/15-function-basics/article.md @@ -1,18 +1,16 @@ # Functions -अक्सर हमें स्क्रिप्ट के कई स्थानों पर इसी तरह की कार्रवाई करने की आवश्यकता होती है। +अक्सर हमें स्क्रिप्ट के कई स्थानों पर इसी तरह की क्रिया करने की आवश्यकता होती है। -उदाहरण के लिए, जब कोई परिदर्शक इन करता है, लॉग आउट करता है और शायद कहीं और एक अच्छा दिखने वाला संदेश दिखाना चाहता है। +उदाहरण के लिए, हमें एक अच्छा दिखने वाला संदेश दिखाना चाहिए जब कोई आगंतुक लॉग इन करता है, लॉग आउट करता है। Functions प्रोग्राम के मुख्य "बिल्डिंग ब्लॉक्स" हैं। वे बिना दोहराव के कोड को कई बार कॉल करने की अनुमति देते हैं। -हम पहले से ही बिल्ट-इन function के उदाहरण देख चुके हैं, जैसे `अलर्ट (संदेश)`, `प्रॉम्प्ट (संदेश, डिफ़ॉल्ट)` और `पुष्टि करें (प्रश्न)`। लेकिन हम अपने स्वयं के functions भी बना सकते हैं। - -## Function Declaration +हम पहले से ही बिल्ट-इन function के उदाहरण देख चुके हैं, जैसे `alert(message)`, `prompt(message, default)` और `confirm(question)`। लेकिन हम अपने स्वयं के functions भी बना सकते हैं। ## Function घोषणा -function बनाने के लिए हम एक _function declaration_ का उपयोग कर सकते हैं। +function बनाने के लिए हम एक _function घोषणा_ का उपयोग कर सकते हैं। यह इस तरह दिख रहा है: @@ -22,7 +20,7 @@ function showMessage() { } ``` -`function` कीवर्ड पहले जाता है, फिर _name of the function_ जाता है, फिर कोष्ठक के बीच _parameters_ की एक सूची (उपरोक्त उदाहरण में खाली) और अंत में function का कोड, जिसे "the function body" भी कहा जाता है , घुंघराले ब्रेसिज़ के बीच। +`function` कीवर्ड पहले जाता है, फिर _function का नाम_ जाता है, फिर कोष्ठक के बीच _parameters_ की एक सूची (उपरोक्त उदाहरण में खाली) और अंत में function का कोड, जिसे "function बॉडी" भी कहा जाता है, घुंघराले ब्रेसिज़ के बीच। ```js function name(parameters) { From 300a818c97c60cf02a2b1e6d078f225b8169b69c Mon Sep 17 00:00:00 2001 From: Rasool Khan <35368463+rskhan167@users.noreply.github.com> Date: Tue, 21 Sep 2021 10:20:44 +0530 Subject: [PATCH 18/36] Update task.md --- .../15-function-basics/2-rewrite-function-question-or/task.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/15-function-basics/2-rewrite-function-question-or/task.md b/1-js/02-first-steps/15-function-basics/2-rewrite-function-question-or/task.md index 0be0d9ccb..287512b0d 100644 --- a/1-js/02-first-steps/15-function-basics/2-rewrite-function-question-or/task.md +++ b/1-js/02-first-steps/15-function-basics/2-rewrite-function-question-or/task.md @@ -18,7 +18,7 @@ function checkAge(age) { } ``` -इसे फिर से लिखें, वही प्रदर्शन करने के लिए, लेकिन बिना `if` के, एक पंक्ति में। +इसे फिर से लिखें, वही कार्य करने के लिए, लेकिन बिना `if` के, एक पंक्ति में। `checkAge` के दो प्रकार बनाएं: From 582983e4c320489b2c4c97a08dcc84a1ee5669a2 Mon Sep 17 00:00:00 2001 From: Rasool Khan <35368463+rskhan167@users.noreply.github.com> Date: Tue, 21 Sep 2021 10:33:33 +0530 Subject: [PATCH 19/36] Update article.md --- 1-js/02-first-steps/15-function-basics/article.md | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/1-js/02-first-steps/15-function-basics/article.md b/1-js/02-first-steps/15-function-basics/article.md index a9c130618..0e8cdcbe7 100644 --- a/1-js/02-first-steps/15-function-basics/article.md +++ b/1-js/02-first-steps/15-function-basics/article.md @@ -12,7 +12,7 @@ Functions प्रोग्राम के मुख्य "बिल्डि function बनाने के लिए हम एक _function घोषणा_ का उपयोग कर सकते हैं। -यह इस तरह दिख रहा है: +यह इस तरह दिखता है: ```js function showMessage() { @@ -49,8 +49,6 @@ showMessage(); यदि हमें कभी भी संदेश या उसके दिखाए जाने के तरीके को बदलने की आवश्यकता होती है, तो यह कोड को एक ही स्थान पर संशोधित करने के लिए पर्याप्त है: वह function जो इसे आउटपुट करता है। -## Local variables - ## लोकल variables किसी function के अंदर घोषित एक variable केवल उस function के अंदर ही दिखाई देता है। @@ -71,8 +69,6 @@ showMessage(); // हैलो, मैं जावास्क्रिप् alert( message ); // <-- Error! variable function के लिए स्थानीय है ``` -## Outer variables - ## बाहरी variables एक function बाहरी variable को भी एक्सेस कर सकता है, उदाहरण के लिए: @@ -178,8 +174,6 @@ showMessage(from, "Hello"); // *Ann*: Hello alert( from ); // Ann ``` -## Default values - ## डिफॉल्ट वैल्यूज यदि कोई parameter प्रदान नहीं किया जाता है, तो उसका मान `undefined` हो जाता है। @@ -219,8 +213,6 @@ function showMessage(from, text = anotherFunction()) { ऊपर दिए गए उदाहरण में, `anotherFunction()` को हर बार `showMessage()` को `text` parameter के बिना कहा जाता है। ``` -### Alternative default parameters - ### वैकल्पिक डिफ़ॉल्ट parameters कभी-कभी function घोषणा में parameter के लिए डिफ़ॉल्ट मान सेट करना समझ में आता है, लेकिन बाद के चरण में, इसके निष्पादन के दौरान भी सेट किया जाता है। @@ -264,8 +256,6 @@ showCount(null); // unknown showCount(); // unknown ``` -## Returning a value - ## एक मान लौटाना एक function परिणाम के रूप में एक मान वापस कॉलिंग कोड में वापस कर सकता है। From c8a43e6664bf72066570d47eb9eeeab8b5f2ac0b Mon Sep 17 00:00:00 2001 From: Rasool Khan <35368463+rskhan167@users.noreply.github.com> Date: Tue, 21 Sep 2021 10:39:57 +0530 Subject: [PATCH 20/36] Update article.md --- 1-js/02-first-steps/15-function-basics/article.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/1-js/02-first-steps/15-function-basics/article.md b/1-js/02-first-steps/15-function-basics/article.md index 0e8cdcbe7..1f63d6cd8 100644 --- a/1-js/02-first-steps/15-function-basics/article.md +++ b/1-js/02-first-steps/15-function-basics/article.md @@ -335,8 +335,7 @@ function doNothing() { alert( doNothing() === undefined ); // true ``` - -````` +```` ````warn header="Never add a newline between `return` and the value" `return` में एक लंबी अभिव्यक्ति के लिए, इसे एक अलग लाइन पर रखना आकर्षक हो सकता है, जैसे: From 1b5f2a9796450f07f464b0973ee21768986984eb Mon Sep 17 00:00:00 2001 From: Rasool Khan <35368463+rskhan167@users.noreply.github.com> Date: Tue, 21 Sep 2021 10:53:01 +0530 Subject: [PATCH 21/36] Update article.md --- 1-js/02-first-steps/15-function-basics/article.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/1-js/02-first-steps/15-function-basics/article.md b/1-js/02-first-steps/15-function-basics/article.md index 1f63d6cd8..c7c24fe70 100644 --- a/1-js/02-first-steps/15-function-basics/article.md +++ b/1-js/02-first-steps/15-function-basics/article.md @@ -107,7 +107,7 @@ alert( userName ); // *!*Bob*/!*, मान function द्वारा सं बाहरी variable का उपयोग केवल तभी किया जाता है जब कोई लोकल न हो। -यदि function के अंदर एक ही नामित variable घोषित किया गया है तो यह _shadows_ बाहरी है। उदाहरण के लिए, नीचे दिए गए कोड में function लोकल `userName` का उपयोग करता है। बाहरी को अनदेखा किया जाता है: +यदि फ़ंक्शन के अंदर एक ही नामित variable घोषित किया जाता है तो यह बाहरी वाले variable को अनदेखा कर देता है। उदाहरण के लिए, नीचे दिए गए कोड में function लोकल `userName` का उपयोग करता है। बाहरी को अनदेखा किया जाता है: ```js run let userName = 'John'; @@ -128,11 +128,11 @@ alert( userName ); // *!*John*/!*, अपरिवर्तित, function ब ``` ```smart header="Global variables" -किसी function के बाहर घोषित variables, जैसे उपरोक्त कोड में बाहरी `userName`, *global* कहलाते हैं। +किसी function के बाहर घोषित variables, जैसे उपरोक्त कोड में बाहरी `userName`, *ग्लोबल* कहलाते हैं। ग्लोबल variables किसी भी function से दिखाई देते हैं (जब तक कि लोकल द्वारा छिपा न हो)। -ग्लोबल variable के उपयोग को कम करने के लिए यह एक अच्छा अभ्यास है। आधुनिक कोड में कुछ या कोई ग्लोबल्स नहीं हैं। अधिकांश variable अपने functions में रहते हैं। हालांकि कभी-कभी, वे प्रोजेक्ट-स्तरीय डेटा संग्रहीत करने के लिए उपयोगी हो सकते हैं। +ग्लोबल variables के उपयोग को कम करना अच्छा अभ्यास है। आधुनिक कोड में कुछ या कोई ग्लोबल्स नहीं हैं। अधिकांश variable अपने functions में रहते हैं। हालांकि कभी-कभी, वे प्रोजेक्ट-स्तरीय डेटा संग्रहीत करने के लिए उपयोगी हो सकते हैं। ``` ## Parameters From 97871c63506ecc9182c66fa75bae615244719692 Mon Sep 17 00:00:00 2001 From: Rasool Khan <35368463+rskhan167@users.noreply.github.com> Date: Tue, 21 Sep 2021 22:08:52 +0530 Subject: [PATCH 22/36] Update task.md --- 1-js/02-first-steps/15-function-basics/4-pow/task.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/15-function-basics/4-pow/task.md b/1-js/02-first-steps/15-function-basics/4-pow/task.md index 097f9cf8a..aa7e9820f 100644 --- a/1-js/02-first-steps/15-function-basics/4-pow/task.md +++ b/1-js/02-first-steps/15-function-basics/4-pow/task.md @@ -12,7 +12,7 @@ pow(3, 3) = 3 * 3 * 3 = 27 pow(1, 100) = 1 * 1 * ...* 1 = 1 ``` -एक वेब-पेज बनाएं जो `x` और `n` के लिए संकेत देता है, और फिर `pow(x,n)` का परिणाम दिखाता है। +एक वेब पेज बनाएं जो `x` और `n` के लिए प्रोम्प्ट करता है, और फिर `pow(x,n)` का परिणाम दिखाता है। [demo] From 4dd3856cc1657611b1b7646b505cbcb8411a6d21 Mon Sep 17 00:00:00 2001 From: Rasool Khan <35368463+rskhan167@users.noreply.github.com> Date: Tue, 21 Sep 2021 22:34:14 +0530 Subject: [PATCH 23/36] Update task.md --- 1-js/02-first-steps/15-function-basics/3-min/task.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/15-function-basics/3-min/task.md b/1-js/02-first-steps/15-function-basics/3-min/task.md index 27a40df27..5d1525214 100644 --- a/1-js/02-first-steps/15-function-basics/3-min/task.md +++ b/1-js/02-first-steps/15-function-basics/3-min/task.md @@ -4,7 +4,7 @@ importance: 1 # Function min(a, b) -एक फ़ंक्शन लिखें `min(a,b)` जो `a` और `b` नंबर में सबसे छोटा है उसको लौटाता है। +एक फ़ंक्शन लिखें `min(a,b)` जो `a` और `b` नंबर में जो सबसे छोटा है उसको लौटाता है। उदाहरण के लिए: From 6b4f6823f7d8a8767bba0f15944a69fe180d1ff3 Mon Sep 17 00:00:00 2001 From: Rasool Khan <35368463+rskhan167@users.noreply.github.com> Date: Tue, 21 Sep 2021 23:25:10 +0530 Subject: [PATCH 24/36] Update task.md --- .../15-function-basics/2-rewrite-function-question-or/task.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/15-function-basics/2-rewrite-function-question-or/task.md b/1-js/02-first-steps/15-function-basics/2-rewrite-function-question-or/task.md index 287512b0d..59d0fc840 100644 --- a/1-js/02-first-steps/15-function-basics/2-rewrite-function-question-or/task.md +++ b/1-js/02-first-steps/15-function-basics/2-rewrite-function-question-or/task.md @@ -18,7 +18,7 @@ function checkAge(age) { } ``` -इसे फिर से लिखें, वही कार्य करने के लिए, लेकिन बिना `if` के, एक पंक्ति में। +इस function को फिर से लिखें, लेकिन बिना `if` के, एक पंक्ति में। `checkAge` के दो प्रकार बनाएं: From 1ff58cc7268455391e6cb2529a13a8d65c4e716c Mon Sep 17 00:00:00 2001 From: Rasool Khan <35368463+rskhan167@users.noreply.github.com> Date: Tue, 21 Sep 2021 23:27:42 +0530 Subject: [PATCH 25/36] Update task.md --- 1-js/02-first-steps/15-function-basics/3-min/task.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/15-function-basics/3-min/task.md b/1-js/02-first-steps/15-function-basics/3-min/task.md index 5d1525214..56af1f434 100644 --- a/1-js/02-first-steps/15-function-basics/3-min/task.md +++ b/1-js/02-first-steps/15-function-basics/3-min/task.md @@ -4,7 +4,7 @@ importance: 1 # Function min(a, b) -एक फ़ंक्शन लिखें `min(a,b)` जो `a` और `b` नंबर में जो सबसे छोटा है उसको लौटाता है। +एक फ़ंक्शन लिखें `min(a,b)` जो `a` और `b` नंबर में से जो सबसे छोटा है उसको लौटाता हो। उदाहरण के लिए: From 5601c3366081621e0849866f6d3c2c064a36bd5c Mon Sep 17 00:00:00 2001 From: Rasool Khan <35368463+rskhan167@users.noreply.github.com> Date: Tue, 21 Sep 2021 23:29:34 +0530 Subject: [PATCH 26/36] Update task.md --- 1-js/02-first-steps/15-function-basics/4-pow/task.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/15-function-basics/4-pow/task.md b/1-js/02-first-steps/15-function-basics/4-pow/task.md index aa7e9820f..5b1d325a8 100644 --- a/1-js/02-first-steps/15-function-basics/4-pow/task.md +++ b/1-js/02-first-steps/15-function-basics/4-pow/task.md @@ -12,7 +12,7 @@ pow(3, 3) = 3 * 3 * 3 = 27 pow(1, 100) = 1 * 1 * ...* 1 = 1 ``` -एक वेब पेज बनाएं जो `x` और `n` के लिए प्रोम्प्ट करता है, और फिर `pow(x,n)` का परिणाम दिखाता है। +एक वेब पेज बनाएं जो `x` और `n` के लिए prompt करता है, और फिर `pow(x,n)` का परिणाम दिखाता है। [demo] From 691397181d632e4a86e9a516fbc488c7c93e439f Mon Sep 17 00:00:00 2001 From: Rasool Khan <35368463+rskhan167@users.noreply.github.com> Date: Tue, 21 Sep 2021 23:30:20 +0530 Subject: [PATCH 27/36] Update task.md --- 1-js/02-first-steps/15-function-basics/4-pow/task.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/15-function-basics/4-pow/task.md b/1-js/02-first-steps/15-function-basics/4-pow/task.md index 5b1d325a8..af06008b4 100644 --- a/1-js/02-first-steps/15-function-basics/4-pow/task.md +++ b/1-js/02-first-steps/15-function-basics/4-pow/task.md @@ -16,4 +16,4 @@ pow(1, 100) = 1 * 1 * ...* 1 = 1 [demo] -नोट: इस टास्क में फ़ंक्शन को केवल `n` के प्राकृतिक मानों को स्वीकार करना चाहिए: `1` से ऊपर के पूर्णांक। +नोट: इस टास्क में function को केवल `n` के प्राकृतिक मानों को स्वीकार करना चाहिए: `1` से ऊपर के पूर्णांक। From f9696ddd5a038b5378eeea39bc8bf54b35d188b2 Mon Sep 17 00:00:00 2001 From: Rasool Khan <35368463+rskhan167@users.noreply.github.com> Date: Tue, 21 Sep 2021 23:58:33 +0530 Subject: [PATCH 28/36] Update article.md --- .../15-function-basics/article.md | 48 +++++++++---------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/1-js/02-first-steps/15-function-basics/article.md b/1-js/02-first-steps/15-function-basics/article.md index c7c24fe70..198d0ede3 100644 --- a/1-js/02-first-steps/15-function-basics/article.md +++ b/1-js/02-first-steps/15-function-basics/article.md @@ -98,7 +98,7 @@ function showMessage() { alert(message); } -alert( userName ); // *!*John*/!* फ़ंक्शन कॉल से पहले +alert( userName ); // *!*John*/!* function कॉल से पहले showMessage(); @@ -107,7 +107,7 @@ alert( userName ); // *!*Bob*/!*, मान function द्वारा सं बाहरी variable का उपयोग केवल तभी किया जाता है जब कोई लोकल न हो। -यदि फ़ंक्शन के अंदर एक ही नामित variable घोषित किया जाता है तो यह बाहरी वाले variable को अनदेखा कर देता है। उदाहरण के लिए, नीचे दिए गए कोड में function लोकल `userName` का उपयोग करता है। बाहरी को अनदेखा किया जाता है: +यदि function के अंदर एक ही नामित variable घोषित किया जाता है तो यह बाहरी वाले variable को अनदेखा कर देता है। उदाहरण के लिए, नीचे दिए गए कोड में function लोकल `userName` का उपयोग करता है। बाहरी को अनदेखा किया जाता है: ```js run let userName = 'John'; @@ -121,7 +121,7 @@ function showMessage() { alert(message); } -// फ़ंक्शन अपना स्वयं का userName बनाएगा और उसका उपयोग करेगा +// function अपना स्वयं का userName बनाएगा और उसका उपयोग करेगा showMessage(); alert( userName ); // *!*John*/!*, अपरिवर्तित, function बाहरी variable का उपयोग नहीं करता है @@ -210,14 +210,14 @@ function showMessage(from, text = anotherFunction()) { ```smart header="Evaluation of default parameters" जावास्क्रिप्ट में, हर बार संबंधित parameter के बिना function को कॉल किए जाने पर एक डिफ़ॉल्ट parameter का मूल्यांकन किया जाता है। -ऊपर दिए गए उदाहरण में, `anotherFunction()` को हर बार `showMessage()` को `text` parameter के बिना कहा जाता है। +ऊपर दिए गए उदाहरण में, `another function()` को हर बार कॉल किया जाता है जब भी `showMessage()` को `text` parameter के बिना कॉल किया जाता है। ``` ### वैकल्पिक डिफ़ॉल्ट parameters कभी-कभी function घोषणा में parameter के लिए डिफ़ॉल्ट मान सेट करना समझ में आता है, लेकिन बाद के चरण में, इसके निष्पादन के दौरान भी सेट किया जाता है। -छोड़े गए पैरामीटर की जांच करने के लिए, हम इसकी तुलना `undefined` से कर सकते हैं: +छोड़े गए parameter की जांच करने के लिए, हम इसकी तुलना `undefined` से कर सकते हैं: ```js run function showMessage(text) { @@ -236,7 +236,7 @@ showMessage(); // खाली संदेश ...या हम `||` ऑपरेटर का उपयोग कर सकते हैं: ```js -// यदि टेक्स्ट पैरामीटर छोड़ा गया है या "" पारित किया गया है, तो इसे 'खाली' पर सेट करें +// यदि टेक्स्ट parameter छोड़ा गया है या "" पास किया गया है, तो इसे 'empty' पर सेट करें function showMessage(text) { text = text || 'empty'; ... @@ -246,7 +246,7 @@ function showMessage(text) { आधुनिक जावास्क्रिप्ट इंजन [nullish coalescing operator](info:nullish-coalescing-operator) `??` को सपोर्ट करती है| यह तब बेहतर होता है जब `0` जैसे झूठे मूल्यों को नियमित माना जाता है: ```js run -// यदि कोई "count" पैरामीटर नहीं है, तो "unknown" दिखाएं +// यदि कोई "count" parameter नहीं है, तो "unknown" दिखाएं function showCount(count) { alert(count ?? "unknown"); } @@ -258,7 +258,7 @@ showCount(); // unknown ## एक मान लौटाना -एक function परिणाम के रूप में एक मान वापस कॉलिंग कोड में वापस कर सकता है। +एक function परिणाम के रूप में एक मान वापस कॉलिंग कोड में लौटा सकता है। सबसे सरल उदाहरण एक ऐसा function होगा जो दो मानों का योग करता है: @@ -283,7 +283,7 @@ function checkAge(age) { */!* } else { *!* - return confirm('क्या आपके पास अपने माता-पिता से अनुमति है?'); + return confirm('क्या आपके पास अपने माता-पिता की अनुमति है?'); */!* } } @@ -314,14 +314,12 @@ function showMovie(age) { } ``` -ऊपर दिए गए कोड में, अगर ` checkAge(age)` `false` लौटाता है, तो `showMovie` `alert` पर आगे नहीं बढ़ेगा। +ऊपर दिए गए कोड में, अगर `checkAge(age)` `false` लौटाता है, तो `showMovie` `alert` पर आगे नहीं बढ़ेगा। ````smart header="A function with an empty `return`or without it returns`undefined`" If a function does not return a value, it is the same as if it returns `undefined`: ```js run -function doNothing() { - /* खाली */ -} +function doNothing() { /* खाली */ } alert( doNothing() === undefined ); // true ``` @@ -344,7 +342,7 @@ alert( doNothing() === undefined ); // true return (some + long + expression + or + whatever * f(a) + f(b)) ``` -यह काम नहीं करता है, क्योंकि `return` के बाद जावास्क्रिप्ट सेमीकोलन लगा देता है । यह उसी तरह काम करेगा: +यह काम नहीं करता है, क्योंकि `return` के बाद जावास्क्रिप्ट सेमीकोलन लगा देता है। यह उसी तरह काम करेगा: ```js return*!*;*/!* @@ -365,13 +363,13 @@ return ( और यह वैसे ही काम करेगा जैसा हम उम्मीद करते हैं। ```` -## एक function का नामकरण [#function-naming] +## Function का नामकरण [#function-naming] Functions क्रिया हैं। तो उनका नाम आमतौर पर एक क्रिया है। यह संक्षिप्त होना चाहिए, यथासंभव सटीक होना चाहिए और यह वर्णन करना चाहिए कि function क्या करता है, ताकि कोड पढ़ने वाले व्यक्ति को यह संकेत मिल सके कि function क्या करता है। क्रिया को अस्पष्ट रूप से वर्णित करने वाले मौखिक उपसर्ग के साथ function प्रारंभ करना एक व्यापक प्रथा है। उपसर्गों के अर्थ पर टीम के भीतर एक समझौता होना चाहिए। -उदाहरण के लिए, `"show"` से शुरू होने वाले फ़ंक्शन आमतौर पर कुछ दिखाते हैं। +उदाहरण के लिए, `"show"` से शुरू होने वाले function आमतौर पर कुछ दिखाते हैं। Function की शुरुआत... @@ -393,21 +391,21 @@ checkPermission(..) // अनुमति की जाँच करता ह उपसर्गों के साथ, function नाम पर एक नज़र यह समझ देती है कि यह किस प्रकार का कार्य करता है और यह किस प्रकार का मूल्य देता है। ```smart header="One function -- one action" -एक function को ठीक वही करना चाहिए जो उसके नाम से सुझाया गया है, और नहीं। +एक function को ठीक वही करना चाहिए जो उसके नाम से सुझाया गया है, और कुछ नहीं। दो स्वतंत्र क्रियाएं आम तौर पर दो functions की सेवा करती हैं, भले ही उन्हें आम तौर पर एक साथ बुलाया जाता है (उस स्थिति में हम एक तीसरा function बना सकते हैं जो उन दोनों को कॉल करता है)। इस नियम को तोड़ने के कुछ उदाहरण: -- `getAge` -- बुरा होगा अगर यह उम्र के साथ एक `alert` दिखाता है (सिर्फ लेना चाहिए )। +- `getAge` -- बुरा होगा अगर यह उम्र के साथ एक `alert` दिखाता है (सिर्फ उम्र लेना चाहिए)। - `createForm` -- खराब होगा यदि यह डॉक्यूमेंट को संशोधित करता है, इसमें एक फॉर्म जोड़ता है (केवल इसे बनाना और वापस करना चाहिए)। - `checkPermission` -- खराब होगा यदि यह `access granted/denied` संदेश प्रदर्शित करता है (केवल जांच करना चाहिए और परिणाम वापस करना चाहिए)। -ये उदाहरण उपसर्गों के सामान्य अर्थ ग्रहण करते हैं। आप और आपकी टीम अन्य अर्थों पर सहमत होने के लिए स्वतंत्र हैं, लेकिन आमतौर पर, वे बहुत भिन्न नहीं होते हैं। किसी भी मामले में, आपको इस बात की पक्की समझ होनी चाहिए कि उपसर्ग का क्या अर्थ है, उपसर्ग का function क्या कर सकता है और क्या नहीं। सभी समान-उपसर्ग फ़ंक्शन को नियमों का पालन करना चाहिए। और टीम को ज्ञान साझा करना चाहिए। +ये उदाहरण उपसर्गों के सामान्य अर्थ ग्रहण करते हैं। आप और आपकी टीम अन्य अर्थों पर सहमत होने के लिए स्वतंत्र हैं, लेकिन आमतौर पर, वे बहुत भिन्न नहीं होते हैं। किसी भी मामले में, आपको इस बात की पक्की समझ होनी चाहिए कि उपसर्ग का क्या अर्थ है, उपसर्ग का function क्या कर सकता है और क्या नहीं। सभी समान-उपसर्ग function को नियमों का पालन करना चाहिए। और टीम को ज्ञान साझा करना चाहिए। ``` ```smart header="Ultrashort function names" -*अक्सर* उपयोग किए जाने वाले फ़ंक्शंस में कभी-कभी अल्ट्रा-शॉर्ट नाम होते हैं। +*अक्सर* उपयोग किए जाने वाले functions में कभी-कभी अल्ट्रा-शॉर्ट नाम होते हैं। उदाहरण के लिए, [jQuery](http://jquery.com) फ्रेमवर्क `$` के साथ एक function को परिभाषित करता है। The [Lodash](http://lodash.com/) library का मुख्य function `_` है। @@ -420,7 +418,7 @@ Functions छोटे होने चाहिए और ठीक एक क एक अलग function न केवल परीक्षण और डीबग करना आसान है - इसका अस्तित्व एक महान comment है! -उदाहरण के लिए, नीचे दिए गए दो कार्यों `showPrimes(n)` की तुलना करें। हर एक `n` तक [अभाज्य संख्याएँ](https://en.wikipedia.org/wiki/Prime_number) आउटपुट करता है। +उदाहरण के लिए, नीचे दिए गए दो functions `showPrimes(n)` की तुलना करें। हर एक `n` तक [अभाज्य संख्याएँ](https://en.wikipedia.org/wiki/Prime_number) आउटपुट करता है। पहला संस्करण एक लेबल का उपयोग करता है: @@ -456,7 +454,7 @@ function isPrime(n) { } ``` -दूसरा संस्करण समझना आसान है, है ना? कोड पीस के बजाय हम क्रिया का एक नाम देखते हैं (`isPrime`)। कभी-कभी लोग ऐसे कोड को _self-describing_ कहते हैं। +दूसरा संस्करण समझना आसान है, है ना? कोड पीस के बजाय हम क्रिया का एक नाम देखते हैं (`isPrime`)। कभी-कभी लोग ऐसे कोड को _स्वयं का वर्णन करना_ कहते हैं। इसलिए, function बनाए जा सकते हैं, भले ही हम उनका पुन: उपयोग करने का इरादा न रखते हों। वे कोड की संरचना करते हैं और इसे पठनीय बनाते हैं। @@ -470,13 +468,13 @@ function name(parameters, delimited, by, comma) { } ``` -- किसी function को दिए गए मान parameters के रूप में उसके local variables में कॉपी किए जाते हैं। +- किसी function को दिए गए मान parameters के रूप में उसके स्थानीय variables में कॉपी किए जाते हैं। - एक function बाहरी variables का इस्तेमाल कर सकता है। लेकिन यह केवल अंदर से बाहर काम करता है। function के बाहर का कोड इसके स्थानीय variables नहीं देखता है। - एक function एक मान वापस कर सकता है। यदि ऐसा नहीं होता है, तो इसका परिणाम `undefined` होता है। -कोड को साफ और समझने में आसान बनाने के लिए, function में मुख्य रूप से local variables और parameter का उपयोग करने की अनुशंसा की जाती है, outer variables नहीं। +कोड को साफ और समझने में आसान बनाने के लिए, function में मुख्य रूप से स्थानीय variables और parameter का उपयोग करने की अनुशंसा की जाती है, बाहरी variables नहीं। -ऐसे function को समझना हमेशा आसान होता है जो पैरामीटर प्राप्त करता है, उनके साथ काम करता है, और किसी ऐसे फ़ंक्शन की तुलना में परिणाम देता है जिसमें कोई पैरामीटर नहीं होता है, लेकिन बाहरी variables को साइड-इफेक्ट के रूप में संशोधित करता है। +ऐसे function को समझना हमेशा आसान होता है जो parameter प्राप्त करता है, उनके साथ काम करता है, और किसी ऐसे function की तुलना में परिणाम देता है जिसमें कोई parameter नहीं होता है, लेकिन बाहरी variables को साइड-इफेक्ट के रूप में संशोधित करता है। Function नामकरण: From 56a438d1bc3326cca33bf4541334a6b812ddda62 Mon Sep 17 00:00:00 2001 From: Rasool Khan <35368463+rskhan167@users.noreply.github.com> Date: Wed, 22 Sep 2021 00:00:57 +0530 Subject: [PATCH 29/36] Update article.md --- 1-js/02-first-steps/15-function-basics/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/15-function-basics/article.md b/1-js/02-first-steps/15-function-basics/article.md index 198d0ede3..9ff176a85 100644 --- a/1-js/02-first-steps/15-function-basics/article.md +++ b/1-js/02-first-steps/15-function-basics/article.md @@ -210,7 +210,7 @@ function showMessage(from, text = anotherFunction()) { ```smart header="Evaluation of default parameters" जावास्क्रिप्ट में, हर बार संबंधित parameter के बिना function को कॉल किए जाने पर एक डिफ़ॉल्ट parameter का मूल्यांकन किया जाता है। -ऊपर दिए गए उदाहरण में, `another function()` को हर बार कॉल किया जाता है जब भी `showMessage()` को `text` parameter के बिना कॉल किया जाता है। +ऊपर दिए गए उदाहरण में, `anotherFunction()` को हर बार कॉल किया जाता है जब भी `showMessage()` को `text` parameter के बिना कॉल किया जाता है। ``` ### वैकल्पिक डिफ़ॉल्ट parameters From 270a3937891e26a09442b485a46a4073f4832701 Mon Sep 17 00:00:00 2001 From: Rasool Khan <35368463+rskhan167@users.noreply.github.com> Date: Mon, 27 Sep 2021 11:14:08 +0530 Subject: [PATCH 30/36] Update article.md --- 1-js/02-first-steps/16-function-expressions/article.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/1-js/02-first-steps/16-function-expressions/article.md b/1-js/02-first-steps/16-function-expressions/article.md index a8ccd6c6c..cddc5dab9 100644 --- a/1-js/02-first-steps/16-function-expressions/article.md +++ b/1-js/02-first-steps/16-function-expressions/article.md @@ -1,8 +1,8 @@ -# Function expressions +# Function व्यंजक -In JavaScript, a function is not a "magical language structure", but a special kind of value. +जावास्क्रिप्ट में, एक function "जादुई भाषा संरचना" नहीं है, बल्कि एक विशेष प्रकार का मूल्य है। -The syntax that we used before is called a *Function Declaration*: +हमने पहले जिस सिंटैक्स का उपयोग किया था, उसे *function घोषणा* कहा जाता है: ```js function sayHi() { @@ -10,9 +10,9 @@ function sayHi() { } ``` -There is another syntax for creating a function that is called a *Function Expression*. +function बनाने के लिए एक और सिंटैक्स है जिसे *फंक्शन व्यंजक* कहा जाता है। -It looks like this: +यह इस तरह दीखता है: ```js let sayHi = function() { From ac357ca611b6e9f556cfd4bf07d395220d5d0bb2 Mon Sep 17 00:00:00 2001 From: Rasool Khan <35368463+rskhan167@users.noreply.github.com> Date: Mon, 27 Sep 2021 11:14:26 +0530 Subject: [PATCH 31/36] Update article.md --- 1-js/02-first-steps/16-function-expressions/article.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/1-js/02-first-steps/16-function-expressions/article.md b/1-js/02-first-steps/16-function-expressions/article.md index cddc5dab9..95bb4fa6a 100644 --- a/1-js/02-first-steps/16-function-expressions/article.md +++ b/1-js/02-first-steps/16-function-expressions/article.md @@ -1,6 +1,6 @@ # Function व्यंजक -जावास्क्रिप्ट में, एक function "जादुई भाषा संरचना" नहीं है, बल्कि एक विशेष प्रकार का मूल्य है। +Javascript में, एक function "जादुई भाषा संरचना" नहीं है, बल्कि एक विशेष प्रकार का मूल्य है। हमने पहले जिस सिंटैक्स का उपयोग किया था, उसे *function घोषणा* कहा जाता है: From 0588885715872cbb590f6e1ae1b394cd83beb8e2 Mon Sep 17 00:00:00 2001 From: Rasool Khan <35368463+rskhan167@users.noreply.github.com> Date: Fri, 1 Oct 2021 14:41:53 +0530 Subject: [PATCH 32/36] Update article.md --- .../16-function-expressions/article.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/1-js/02-first-steps/16-function-expressions/article.md b/1-js/02-first-steps/16-function-expressions/article.md index 95bb4fa6a..3898da877 100644 --- a/1-js/02-first-steps/16-function-expressions/article.md +++ b/1-js/02-first-steps/16-function-expressions/article.md @@ -20,11 +20,11 @@ let sayHi = function() { }; ``` -Here, the function is created and assigned to the variable explicitly, like any other value. No matter how the function is defined, it's just a value stored in the variable `sayHi`. +यहां, function को किसी अन्य मान की तरह, स्पष्ट रूप से बनाया गया है और variable को असाइन किया गया है। कोई फर्क नहीं पड़ता कि function को कैसे परिभाषित किया गया है, यह केवल 'sayHi' variable में संग्रहीत एक मान है। -The meaning of these code samples is the same: "create a function and put it into the variable `sayHi`". +इन कोड नमूनों का अर्थ एक ही है: "एक function बनाएं और इसे variable `sayHi` में डालें"। -We can even print out that value using `alert`: +हम `alert` का उपयोग करके उस मूल्य को प्रिंट भी कर सकते हैं: ```js run function sayHi() { @@ -36,15 +36,15 @@ alert( sayHi ); // shows the function code */!* ``` -Please note that the last line does not run the function, because there are no parentheses after `sayHi`. There are programming languages where any mention of a function name causes its execution, but JavaScript is not like that. +कृपया ध्यान दें कि अंतिम पंक्ति function नहीं चलाती है, क्योंकि `sayHi` के बाद कोई कोष्ठक नहीं है। ऐसी प्रोग्रामिंग भाषाएं हैं जहां किसी function नाम का कोई उल्लेख इसके निष्पादन का कारण बनता है, लेकिन Javascript ऐसा नहीं है। -In JavaScript, a function is a value, so we can deal with it as a value. The code above shows its string representation, which is the source code. +Javascript में, एक function एक मान है, इसलिए हम इसे एक मान के रूप में व्यवहार कर सकते हैं। उपरोक्त कोड इसका स्ट्रिंग प्रतिनिधित्व दिखाता है, जो स्रोत कोड है। -Surely, a function is a special value, in the sense that we can call it like `sayHi()`. +निश्चित रूप से, एक function एक विशेष मूल्य है, इस अर्थ में कि हम इसे `sayHi()` की तरह कॉल कर सकते हैं। -But it's still a value. So we can work with it like with other kinds of values. +लेकिन यह फिर भी एक मूल्य है। इसलिए हम इसके साथ अन्य प्रकार के मूल्यों की तरह काम कर सकते हैं। -We can copy a function to another variable: +हम एक function को दूसरे variable में कॉपी कर सकते हैं: ```js run no-beautify function sayHi() { // (1) create From 7611a3f3a799ab2bdfeefbda2520045c0848dc2b Mon Sep 17 00:00:00 2001 From: Rasool Khan <35368463+rskhan167@users.noreply.github.com> Date: Thu, 14 Oct 2021 19:44:28 +0530 Subject: [PATCH 33/36] Update article.md --- 1-js/02-first-steps/16-function-expressions/article.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/1-js/02-first-steps/16-function-expressions/article.md b/1-js/02-first-steps/16-function-expressions/article.md index 3898da877..9fc359bcf 100644 --- a/1-js/02-first-steps/16-function-expressions/article.md +++ b/1-js/02-first-steps/16-function-expressions/article.md @@ -1,8 +1,8 @@ -# Function व्यंजक +# Function expressions -Javascript में, एक function "जादुई भाषा संरचना" नहीं है, बल्कि एक विशेष प्रकार का मूल्य है। +In JavaScript, a function is not a "magical language structure", but a special kind of value. -हमने पहले जिस सिंटैक्स का उपयोग किया था, उसे *function घोषणा* कहा जाता है: +The syntax that we used before is called a *Function Declaration*: ```js function sayHi() { @@ -10,9 +10,9 @@ function sayHi() { } ``` -function बनाने के लिए एक और सिंटैक्स है जिसे *फंक्शन व्यंजक* कहा जाता है। +There is another syntax for creating a function that is called a *Function Expression*. -यह इस तरह दीखता है: +It looks like this: ```js let sayHi = function() { From 3ad84fb6a5580d04228aeeebd0e9683d642fa0e3 Mon Sep 17 00:00:00 2001 From: Rasool Khan <35368463+rskhan167@users.noreply.github.com> Date: Thu, 14 Oct 2021 19:46:20 +0530 Subject: [PATCH 34/36] Update article.md --- .../16-function-expressions/article.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/1-js/02-first-steps/16-function-expressions/article.md b/1-js/02-first-steps/16-function-expressions/article.md index 9fc359bcf..a8ccd6c6c 100644 --- a/1-js/02-first-steps/16-function-expressions/article.md +++ b/1-js/02-first-steps/16-function-expressions/article.md @@ -20,11 +20,11 @@ let sayHi = function() { }; ``` -यहां, function को किसी अन्य मान की तरह, स्पष्ट रूप से बनाया गया है और variable को असाइन किया गया है। कोई फर्क नहीं पड़ता कि function को कैसे परिभाषित किया गया है, यह केवल 'sayHi' variable में संग्रहीत एक मान है। +Here, the function is created and assigned to the variable explicitly, like any other value. No matter how the function is defined, it's just a value stored in the variable `sayHi`. -इन कोड नमूनों का अर्थ एक ही है: "एक function बनाएं और इसे variable `sayHi` में डालें"। +The meaning of these code samples is the same: "create a function and put it into the variable `sayHi`". -हम `alert` का उपयोग करके उस मूल्य को प्रिंट भी कर सकते हैं: +We can even print out that value using `alert`: ```js run function sayHi() { @@ -36,15 +36,15 @@ alert( sayHi ); // shows the function code */!* ``` -कृपया ध्यान दें कि अंतिम पंक्ति function नहीं चलाती है, क्योंकि `sayHi` के बाद कोई कोष्ठक नहीं है। ऐसी प्रोग्रामिंग भाषाएं हैं जहां किसी function नाम का कोई उल्लेख इसके निष्पादन का कारण बनता है, लेकिन Javascript ऐसा नहीं है। +Please note that the last line does not run the function, because there are no parentheses after `sayHi`. There are programming languages where any mention of a function name causes its execution, but JavaScript is not like that. -Javascript में, एक function एक मान है, इसलिए हम इसे एक मान के रूप में व्यवहार कर सकते हैं। उपरोक्त कोड इसका स्ट्रिंग प्रतिनिधित्व दिखाता है, जो स्रोत कोड है। +In JavaScript, a function is a value, so we can deal with it as a value. The code above shows its string representation, which is the source code. -निश्चित रूप से, एक function एक विशेष मूल्य है, इस अर्थ में कि हम इसे `sayHi()` की तरह कॉल कर सकते हैं। +Surely, a function is a special value, in the sense that we can call it like `sayHi()`. -लेकिन यह फिर भी एक मूल्य है। इसलिए हम इसके साथ अन्य प्रकार के मूल्यों की तरह काम कर सकते हैं। +But it's still a value. So we can work with it like with other kinds of values. -हम एक function को दूसरे variable में कॉपी कर सकते हैं: +We can copy a function to another variable: ```js run no-beautify function sayHi() { // (1) create From e37cbf2c1bbddee9a0444acc79ecf1e85a2fd34a Mon Sep 17 00:00:00 2001 From: Rasool Khan <35368463+rskhan167@users.noreply.github.com> Date: Fri, 15 Oct 2021 17:36:28 +0530 Subject: [PATCH 35/36] Update task.md --- 1-js/02-first-steps/15-function-basics/3-min/task.md | 1 + 1 file changed, 1 insertion(+) diff --git a/1-js/02-first-steps/15-function-basics/3-min/task.md b/1-js/02-first-steps/15-function-basics/3-min/task.md index 56af1f434..cfb65f534 100644 --- a/1-js/02-first-steps/15-function-basics/3-min/task.md +++ b/1-js/02-first-steps/15-function-basics/3-min/task.md @@ -13,3 +13,4 @@ min(2, 5) == 2 min(3, -1) == -1 min(1, 1) == 1 ``` + From a04785d00530c3cff8f1b0ca132490fa9a21ceac Mon Sep 17 00:00:00 2001 From: Rasool Khan <35368463+rskhan167@users.noreply.github.com> Date: Fri, 15 Oct 2021 17:39:03 +0530 Subject: [PATCH 36/36] Update task.md --- 1-js/02-first-steps/15-function-basics/3-min/task.md | 1 - 1 file changed, 1 deletion(-) diff --git a/1-js/02-first-steps/15-function-basics/3-min/task.md b/1-js/02-first-steps/15-function-basics/3-min/task.md index cfb65f534..56af1f434 100644 --- a/1-js/02-first-steps/15-function-basics/3-min/task.md +++ b/1-js/02-first-steps/15-function-basics/3-min/task.md @@ -13,4 +13,3 @@ min(2, 5) == 2 min(3, -1) == -1 min(1, 1) == 1 ``` -