-
Notifications
You must be signed in to change notification settings - Fork 9
Logical operators #82
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
Merged
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
eb51f73
article.md to line 19
vahmelk99 27c1964
OR operator ended
vahmelk99 7a0456e
&& translated
vahmelk99 e57228d
article added
vahmelk99 ac13025
importance translated
vahmelk99 6612518
1-alert-null-2-undefined translated
vahmelk99 b662a96
3-alert-1-null-2 translated
vahmelk99 c0cdc9a
2-alert-or translated
vahmelk99 7646dd5
2-alert-or translated
vahmelk99 f0d57a5
4-alert-and translated
vahmelk99 54448c2
5-alert-and-or translated
vahmelk99 5895fdc
titles rename and 6th ex.
vahmelk99 7b2e8c7
7-check-if-out-range translated
vahmelk99 ccc824f
8-if-question translated
vahmelk99 1bb3af5
start translating 9-check-login
vahmelk99 addba0d
Merge branch 'master' of https://github.com/vahmelk99/hy.javascript.info
vahmelk99 61801fd
9-check-login translated
vahmelk99 fe68296
translation bugfixes in logical operators
vahmelk99 1f1ea7d
Update 1-js/02-first-steps/11-logical-operators/3-alert-1-null-2/solu…
vahmelk99 87442eb
Update 1-js/02-first-steps/11-logical-operators/4-alert-and/task.md
vahmelk99 8b25f3b
Update 1-js/02-first-steps/11-logical-operators/article.md
vahmelk99 dab4805
Update 1-js/02-first-steps/11-logical-operators/article.md
vahmelk99 34f3333
Update 1-js/02-first-steps/11-logical-operators/article.md
vahmelk99 dde7793
Update 1-js/02-first-steps/11-logical-operators/article.md
vahmelk99 a12a35c
Update 1-js/02-first-steps/11-logical-operators/article.md
vahmelk99 d85ba1b
Update 1-js/02-first-steps/11-logical-operators/article.md
vahmelk99 a99cafd
article fixed
vahmelk99 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
3 changes: 1 addition & 2 deletions
3
1-js/02-first-steps/11-logical-operators/1-alert-null-2-undefined/solution.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
The answer is `2`, that's the first truthy value. | ||
Պատասխանը `2` է, քանի որ այն առաջին ճշմարիտ արժեքն է։ | ||
|
||
```js run | ||
alert( null || 2 || undefined ); | ||
``` | ||
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 6 additions & 6 deletions
12
1-js/02-first-steps/11-logical-operators/2-alert-or/solution.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
The answer: first `1`, then `2`. | ||
Այն կտպի `1`, այնուհետև `2`։ | ||
|
||
```js run | ||
alert( alert(1) || 2 || alert(3) ); | ||
``` | ||
|
||
The call to `alert` does not return a value. Or, in other words, it returns `undefined`. | ||
`alert`֊ի կանչը չի վերադարձնում ոչ մի արժեք։ Կամ այլ կերպ ասած վերադարձնում է `undefined`։ | ||
|
||
1. The first OR `||` evaluates its left operand `alert(1)`. That shows the first message with `1`. | ||
2. The `alert` returns `undefined`, so OR goes on to the second operand searching for a truthy value. | ||
3. The second operand `2` is truthy, so the execution is halted, `2` is returned and then shown by the outer alert. | ||
1. Սկզբում ԿԱՄ `||`֊ը հաշվում (evaluates) է իր ձախ կողմի օպերանդը՝ `alert(1)`, որն էլ էկրանին ցույց է տալիս `1` արժեքը։ | ||
2. `alert`֊ը վերադարձնում է `undefined`։ ԿԱՄ֊ը անցնում է երկրորդ օպերանդին՝ որոնելով ճշմարիտ արժեք։ | ||
3. Երկրորդ օպերանդը `2` է, որը ճշմարիտ է, և ԿԱՄ֊ը դադարեցնում է իր հաշվարկները։ `2`֊ը վերադարձվում է և ցուցադրվում էկրանին դրսի `alert`֊ի միջոցով։ | ||
|
||
There will be no `3`, because the evaluation does not reach `alert(3)`. | ||
`3`֊ը չի երևա էկրանին, քանի որ ԿԱՄ֊ը կանգ է առնում երկրորդ օպերանդի վրա և չի հասնում `alert(3)`֊ին։ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
1-js/02-first-steps/11-logical-operators/3-alert-1-null-2/solution.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
1-js/02-first-steps/11-logical-operators/4-alert-and/solution.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
The answer: `1`, and then `undefined`. | ||
Այն կտպի `1`, այնուհետև `undefined`։ | ||
|
||
```js run | ||
alert( alert(1) && alert(2) ); | ||
``` | ||
|
||
The call to `alert` returns `undefined` (it just shows a message, so there's no meaningful return). | ||
`alert`֊ի կանչը տպում է էկրանին և վերադարձնում `undefined`։ | ||
|
||
Because of that, `&&` evaluates the left operand (outputs `1`), and immediately stops, because `undefined` is a falsy value. And `&&` looks for a falsy value and returns it, so it's done. | ||
Այդ պատճառով, երբ `&&`֊ը ավարտում է ձախ օպերանդի հաշվարկը (էկրանին ցուցադրում է `1`), անմիջապես կանգ է առնում, քանի որ `undefined`֊ը սխալական արժեք է։ `&&`֊ը փնտրում է առաջին սխալական արժեքը և վերադարձնում այն։ | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
1-js/02-first-steps/11-logical-operators/5-alert-and-or/solution.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
The answer: `3`. | ||
Պատասխանը `3` է։ | ||
|
||
```js run | ||
alert( null || 2 && 3 || 4 ); | ||
``` | ||
|
||
The precedence of AND `&&` is higher than `||`, so it executes first. | ||
ԵՎ `&&`֊ի նախապատվությունը ավելի բարձր է քան `||`֊ինը, հետևաբար այն ավելի շուտ կկատարվի։ | ||
|
||
The result of `2 && 3 = 3`, so the expression becomes: | ||
Քանի որ `2 && 3 = 3`, ապա կստանանք հետևյալ արտահայտությունը․ | ||
|
||
``` | ||
null || 3 || 4 | ||
``` | ||
|
||
Now the result is the first truthy value: `3`. | ||
Եվ կստանանք պատասխանը առաջին ճշմարիտ արժեքը՝ `3`։ | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
1-js/02-first-steps/11-logical-operators/7-check-if-out-range/solution.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 12 additions & 12 deletions
24
1-js/02-first-steps/11-logical-operators/8-if-question/solution.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
The answer: the first and the third will execute. | ||
Պատասխան՝ առաջին և երրորդ `alert`֊ները կկանչվեն։ | ||
|
||
Details: | ||
Մանրամասներ․ | ||
|
||
```js run | ||
// Runs. | ||
// The result of -1 || 0 = -1, truthy | ||
if (-1 || 0) alert( 'first' ); | ||
// Կանչվում է, | ||
// քանի որ -1 || 0 = -1 ճշմարիտ է | ||
if (-1 || 0) alert('առաջին') | ||
|
||
// Doesn't run | ||
// -1 && 0 = 0, falsy | ||
if (-1 && 0) alert( 'second' ); | ||
// Չի կանչվում, | ||
// քանի որ -1 && 0 = 0 սխալական է | ||
if (-1 && 0) alert('երկրորդ') | ||
|
||
// Executes | ||
// Operator && has a higher precedence than || | ||
// so -1 && 1 executes first, giving us the chain: | ||
// Կնչվում է, քանի որ | ||
// && օպերատորի նախապատվությունը ավելի բարձր է, քան ||֊ինը, | ||
// այսպիսով -1 && 1 հաշվվում է առաջինը։ Ստանում ենք հետևյալ շղթան․ | ||
// null || -1 && 1 -> null || 1 -> 1 | ||
if (null || -1 && 1) alert( 'third' ); | ||
if (null || -1 && 1) alert('երրորդ') | ||
``` | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.