Skip to content

Functions #75

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 41 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
c594079
Translate 1-if-else-required
rasoolkhan16 Sep 6, 2021
e2877f1
Translate 2-rewrite-function-question0or
rasoolkhan16 Sep 6, 2021
722a4e1
fix numbering
rskhan167 Sep 6, 2021
906f4e8
fix autochange done by IDE
rskhan167 Sep 6, 2021
0c4bd5e
fix changes made by IDE
rskhan167 Sep 6, 2021
1e5439e
Translate 3-min
rskhan167 Sep 6, 2021
fbb4ea7
Merge branch 'master' of github-personal:rskhan167/hi.javascript.info
rskhan167 Sep 6, 2021
f0d15ad
fix autochange by IDE
rskhan167 Sep 6, 2021
952f447
Translate article
rskhan167 Sep 9, 2021
74b6581
Merge branch 'master' of github-personal:rskhan167/hi.javascript.info
rskhan167 Sep 9, 2021
b632892
fix translate
rskhan167 Sep 9, 2021
1d42753
fix IDE's autochanges
rskhan167 Sep 9, 2021
93aa7be
fix IDE's autochanges
rskhan167 Sep 9, 2021
f39ab2b
fix IDE's autochanges
rskhan167 Sep 9, 2021
5bf0d16
fix some translations
rskhan167 Sep 14, 2021
badd33b
Update task.md
rskhan167 Sep 21, 2021
1eac281
Update task.md
rskhan167 Sep 21, 2021
de48b64
Update task.md
rskhan167 Sep 21, 2021
dc463a3
Update article.md
rskhan167 Sep 21, 2021
300a818
Update task.md
rskhan167 Sep 21, 2021
582983e
Update article.md
rskhan167 Sep 21, 2021
c8a43e6
Update article.md
rskhan167 Sep 21, 2021
1b5f2a9
Update article.md
rskhan167 Sep 21, 2021
97871c6
Update task.md
rskhan167 Sep 21, 2021
4dd3856
Update task.md
rskhan167 Sep 21, 2021
6b4f682
Update task.md
rskhan167 Sep 21, 2021
1ff58cc
Update task.md
rskhan167 Sep 21, 2021
5601c33
Update task.md
rskhan167 Sep 21, 2021
6913971
Update task.md
rskhan167 Sep 21, 2021
f9696dd
Update article.md
rskhan167 Sep 21, 2021
56a438d
Update article.md
rskhan167 Sep 21, 2021
c8ecd51
Merge branch 'javascript-tutorial:master' into master
rskhan167 Sep 23, 2021
7b70801
Merge branch 'javascript-tutorial:master' into master
rskhan167 Sep 27, 2021
270a393
Update article.md
rskhan167 Sep 27, 2021
ac357ca
Update article.md
rskhan167 Sep 27, 2021
0588885
Update article.md
rskhan167 Oct 1, 2021
7611a3f
Update article.md
rskhan167 Oct 14, 2021
3ad84fb
Update article.md
rskhan167 Oct 14, 2021
e37cbf2
Update task.md
rskhan167 Oct 15, 2021
a04785d
Update task.md
rskhan167 Oct 15, 2021
d5900ab
Merge branch 'javascript-tutorial:master' into master
rskhan167 Oct 15, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1 +1 @@
No difference.
कोई फर्क नहीं।
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ importance: 4

---

# Is "else" required?
# क्या "else" आवश्यक है?

The following function returns `true` if the parameter `age` is greater than `18`.
यदि `age` parameter `18` से अधिक है, तो निम्नलिखित function `true` लौटाता है।

Otherwise it asks for a confirmation and returns its result:
अन्यथा, यह एक पुष्टिकरण मांगता है और अपना परिणाम देता है:

```js
function checkAge(age) {
Expand All @@ -15,13 +15,13 @@ function checkAge(age) {
*!*
} else {
// ...
return confirm('Did parents allow you?');
return confirm('क्या माता-पिता ने आपको अनुमति दी थी?');
}
*/!*
}
```

Will the function work differently if `else` is removed?
यदि `else` हटा दिया जाता है तो क्या function अलग तरह से काम करेगा?

```js
function checkAge(age) {
Expand All @@ -30,9 +30,9 @@ function checkAge(age) {
}
*!*
// ...
return confirm('Did parents allow you?');
return confirm('क्या माता-पिता ने आपको अनुमति दी थी?');
*/!*
}
```

Is there any difference in the behavior of these two variants?
क्या इन दोनों रूपों के व्यवहार में कोई अंतर है?
Original file line number Diff line number Diff line change
@@ -1,17 +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('क्या माता-पिता ने आपको अनुमति दी थी?');
}
```

Using OR `||` (the shortest variant):
OR ऑपरेटर का उपयोग करते हुए `||` (सबसे छोटा संस्करण)

```js
function checkAge(age) {
return (age > 18) || confirm('Did parents allow you?');
return (age > 18) || confirm('क्या माता-पिता ने आपको अनुमति दी थ?');
}
```

Note that the parentheses around `age > 18` are not required here. They exist for better readabilty.
ध्यान दें कि यहां `age > 18` के आसपास के कोष्ठकों की आवश्यकता नहीं है। वे बेहतर पठनीयता के लिए मौजूद हैं।
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@ importance: 4

---

# Rewrite the function using '?' or '||'
# '?' या '||' का उपयोग करके function को फिर से लिखें|

The following function returns `true` if the parameter `age` is greater than `18`.
यदि `age` parameter `18` से अधिक है, तो निम्नलिखित function `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("क्या माता-पिता ने आपको अनुमति दी थी?");
}
}
```

Rewrite it, to perform the same, but without `if`, in a single line.
इस function को फिर से लिखें, लेकिन बिना `if` के, एक पंक्ति में।

Make two variants of `checkAge`:
`checkAge` के दो प्रकार बनाएं:

1. Using a question mark operator `?`
2. Using OR `||`
1. प्रश्न चिह्न ऑपरेटर का उपयोग करते हुए `?`
2. OR ऑपरेटर का उपयोग करते हुए `||`
6 changes: 3 additions & 3 deletions 1-js/02-first-steps/15-function-basics/3-min/solution.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
A solution using `if`:
`if` का उपयोग करके एक हल:

```js
function min(a, b) {
Expand All @@ -10,12 +10,12 @@ function min(a, b) {
}
```

A solution with a question mark operator `'?'`:
प्रश्न चिह्न ऑपरेटर `'?'` के साथ एक हल:

```js
function min(a, b) {
return a < b ? a : b;
}
```

P.S. In the case of an equality `a == b` it does not matter what to return.
नोट: समानता `a == b` के मामले में यह मायने नहीं रखता कि क्या लौटाया जाए।
5 changes: 2 additions & 3 deletions 1-js/02-first-steps/15-function-basics/3-min/task.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ importance: 1

# Function 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
```

6 changes: 3 additions & 3 deletions 1-js/02-first-steps/15-function-basics/4-pow/task.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ 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.
एक फ़ंक्शन लिखें `pow(x,n)` जो `x` को `n` की घात में लौटाता है। या, दूसरे शब्दों में, `x` को अपने आप से `n` बार गुणा करता है और परिणाम देता है।

```js
pow(3, 2) = 3 * 3 = 9
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` के लिए prompt करता है, और फिर `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` से ऊपर के पूर्णांक।
Loading