Repository navigation
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 17 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
5 changes: 2 additions & 3 deletions
5
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 ); | ||
| alert(null || 2 || undefined) | ||
| ``` | ||
|
|
||
|
bugron marked this conversation as resolved.
|
||
9 changes: 4 additions & 5 deletions
9
1-js/02-first-steps/11-logical-operators/1-alert-null-2-undefined/task.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,12 +1,11 @@ | ||
| importance: 5 | ||
| Կարևորություն: 5 | ||
|
bugron marked this conversation as resolved.
Outdated
|
||
|
|
||
| --- | ||
|
|
||
| # What's the result of OR? | ||
| # Ի՞նչ է հետևյալ ԿԱՄ-ով արտահայտության արդյունքը | ||
|
|
||
| What is the code below going to output? | ||
| Ի՞նչ կտպի ներքևում գրված ծրագիրը։ | ||
|
|
||
| ```js | ||
| alert( null || 2 || undefined ); | ||
| alert(null || 2 || undefined) | ||
|
bugron marked this conversation as resolved.
Outdated
|
||
| ``` | ||
|
|
||
|
bugron marked this conversation as resolved.
|
||
14 changes: 7 additions & 7 deletions
14
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) ); | ||
| alert(alert(1) || 2 || alert(3)) | ||
|
bugron marked this conversation as resolved.
Outdated
|
||
| ``` | ||
|
|
||
| The call to `alert` does not return a value. Or, in other words, it returns `undefined`. | ||
| `alert`֊ի կանչը չի վերադարձնում ոչ մի արժեք։ Կամ այլ կերպա ասած վերադարձնում է `undefined`։ | ||
|
bugron marked this conversation as resolved.
Outdated
|
||
|
|
||
| 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`֊ի միջոցով։ | ||
|
bugron marked this conversation as resolved.
Outdated
|
||
|
|
||
| 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,11 @@ | ||
| importance: 3 | ||
| Կարևորություն: 3 | ||
|
bugron marked this conversation as resolved.
Outdated
|
||
|
|
||
| --- | ||
|
|
||
| # What's the result of OR'ed alerts? | ||
| # Ի՞նչ է հետևյալ ԿԱՄ-ով արտահայտության արդյունքը | ||
|
|
||
| What will the code below output? | ||
| Ի՞նչ կտպի ներքևում գրված ծրագիրը։ | ||
|
|
||
| ```js | ||
| alert( alert(1) || 2 || alert(3) ); | ||
| alert(alert(1) || 2 || alert(3)) | ||
|
bugron marked this conversation as resolved.
Outdated
|
||
| ``` | ||
|
|
||
|
bugron marked this conversation as resolved.
|
||
4 changes: 2 additions & 2 deletions
4
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| The answer: `null`, because it's the first falsy value from the list. | ||
| Պատասխանը `null` է, քանի որ այն առաջին սխալական արժեքն է։ | ||
|
|
||
| ```js run | ||
| alert( 1 && null && 2 ); | ||
| alert(1 && null && 2) | ||
|
bugron marked this conversation as resolved.
Outdated
|
||
| ``` | ||
|
|
||
9 changes: 4 additions & 5 deletions
9
1-js/02-first-steps/11-logical-operators/3-alert-1-null-2/task.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,12 +1,11 @@ | ||
| importance: 5 | ||
| Կարևորություն: 5 | ||
|
bugron marked this conversation as resolved.
Outdated
|
||
|
|
||
| --- | ||
|
|
||
| # What is the result of AND? | ||
| # Ի՞նչ է հետևյալ ԵՎ-ով արտահայտության արդյունքը: | ||
|
|
||
| What is this code going to show? | ||
| Ի՞նչ կտպի ներքևում գրված ծրագիրը։ | ||
|
|
||
| ```js | ||
| alert( 1 && null && 2 ); | ||
| alert(1 && null && 2) | ||
|
bugron marked this conversation as resolved.
Outdated
|
||
| ``` | ||
|
|
||
|
bugron marked this conversation as resolved.
|
||
8 changes: 4 additions & 4 deletions
8
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) ); | ||
| alert(alert(1) && alert(2)); | ||
|
bugron marked this conversation as resolved.
Outdated
|
||
| ``` | ||
|
|
||
| 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,11 @@ | ||
| importance: 3 | ||
| Կարևորություն: 3 | ||
|
bugron marked this conversation as resolved.
Outdated
|
||
|
|
||
| --- | ||
|
|
||
| # What is the result of AND'ed alerts? | ||
| # Ի՞նչ է հետևյալ ԵՎ-ով արտահայտության արդյունքը | ||
|
|
||
| What will this code show? | ||
| Ի՞նչ կտպի ներքևում գրված ծրագիրը։ | ||
|
|
||
| ```js | ||
| alert( alert(1) && alert(2) ); | ||
| alert(alert(1) && alert(2)) | ||
|
bugron marked this conversation as resolved.
Outdated
|
||
| ``` | ||
|
|
||
|
bugron marked this conversation as resolved.
|
||
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`։ | ||
|
|
7 changes: 3 additions & 4 deletions
7
1-js/02-first-steps/11-logical-operators/5-alert-and-or/task.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,12 +1,11 @@ | ||
| importance: 5 | ||
| Կարևորություն: 5 | ||
|
bugron marked this conversation as resolved.
Outdated
|
||
|
|
||
| --- | ||
|
|
||
| # The result of OR AND OR | ||
| # Ի՞նչ է հետևյալ ԵՎ-ով և ԿԱՄ֊ով արտահայտության արդյունքը | ||
|
|
||
| What will the result be? | ||
| Ի՞նչ կտպի ներքևում գրված ծրագիրը։ | ||
|
|
||
| ```js | ||
| alert( null || 2 && 3 || 4 ); | ||
| ``` | ||
|
|
||
|
bugron marked this conversation as resolved.
|
||
8 changes: 4 additions & 4 deletions
8
1-js/02-first-steps/11-logical-operators/6-check-if-in-range/task.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,9 +1,9 @@ | ||
| importance: 3 | ||
| Կարևորություն: 3 | ||
|
bugron marked this conversation as resolved.
Outdated
|
||
|
|
||
| --- | ||
|
|
||
| # Check the range between | ||
| # Միջակայքի ստուգում | ||
|
|
||
| Write an `if` condition to check that `age` is between `14` and `90` inclusively. | ||
| Գրեք `if` պայման, որը կստուգի արդյոք `age` փոփոխականը ընկած է `14` և `90` թվերի միջակայքում, այդ թվերը ներառյալ։ | ||
|
|
||
| "Inclusively" means that `age` can reach the edges `14` or `90`. | ||
| "Ներառյալ" նշանակում է, որ `age`֊ը կարող է ընդունել `14` կամ `90` արժեքները նույնպես։ | ||
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
8 changes: 4 additions & 4 deletions
8
1-js/02-first-steps/11-logical-operators/7-check-if-out-range/task.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,9 +1,9 @@ | ||
| importance: 3 | ||
| Կարևորություն: 3 | ||
|
bugron marked this conversation as resolved.
Outdated
|
||
|
|
||
| --- | ||
|
|
||
| # Check the range outside | ||
| # Միջակայքից դուրս ստուգում | ||
|
|
||
| Write an `if` condition to check that `age` is NOT between `14` and `90` inclusively. | ||
| Գրեք `if` պայման, որը կստուգի արդյոք `age` փոփոխականը ընկած ՉԷ `14` և `90` թվերի միջակայքում, այդ թվերը ներառյալ։ | ||
|
|
||
| Create two variants: the first one using NOT `!`, the second one -- without it. | ||
| Խնդրիը լուծեք երկու եղանակով․ առաջինը օգտագործելով ՈՉ `!` օպերատորը, երկրորդը առանց ՈՉ֊ի։ | ||
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('երրորդ') | ||
| ``` | ||
|
|
15 changes: 7 additions & 8 deletions
15
1-js/02-first-steps/11-logical-operators/8-if-question/task.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,15 @@ | ||
| importance: 5 | ||
| Կարևորություն: 5 | ||
|
bugron marked this conversation as resolved.
Outdated
|
||
|
|
||
| --- | ||
|
|
||
| # A question about "if" | ||
| # Հարց "if"֊ի մասին | ||
|
|
||
| Which of these `alert`s are going to execute? | ||
| Այս `alert`֊ներից որո՞նք կաշխատեն։ | ||
|
|
||
| What will the results of the expressions be inside `if(...)`? | ||
| Ի՞նչ կլինի `if(...)`֊երի ներսում գրված արտահայտությունների արժեքները։ | ||
|
|
||
| ```js | ||
| if (-1 || 0) alert( 'first' ); | ||
| if (-1 && 0) alert( 'second' ); | ||
| if (null || -1 && 1) alert( 'third' ); | ||
| if (-1 || 0) alert('առաջին') | ||
| if (-1 && 0) alert('երկրորդ') | ||
| if (null || -1 && 1) alert('երրորդ') | ||
| ``` | ||
|
|
||
|
bugron marked this conversation as resolved.
|
||
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.