- Notifications
You must be signed in to change notification settings - Fork179
Logical operators#34
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
tarasyyyk merged 10 commits intojavascript-tutorial:masterfromZim123:1_02_11_logical_operatorsJul 16, 2019
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
10 commits Select commitHold shift + click to select a range
ddffb12
saving progress
Zim12381b1fd9
saveing progress
Zim12319f815e
Merge branch 'master' into 1_02_11_logical_operators
Zim123d3fa813
saving progress
Zim123bbfdd3d
saving progress
Zim123483de94
saving progress
Zim12340f8158
finished translation
Zim1233e94d80
Merge branch 'master' into 1_02_11_logical_operators
Zim123903f3ef
crrections
Zim123f126cba
after review corrections
Zim123File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
2 changes: 1 addition & 1 deletion1-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,4 +1,4 @@ | ||
Відповідь`2`,це перше правдиве значення. | ||
```js run | ||
alert( null || 2 || undefined ); | ||
4 changes: 2 additions & 2 deletions1-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 |
---|---|---|
@@ -2,9 +2,9 @@ importance: 5 | ||
--- | ||
#Який результат АБО? | ||
Що виведе код нижче? | ||
```js | ||
alert( null || 2 || undefined ); | ||
12 changes: 6 additions & 6 deletions1-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 @@ | ||
Відповідь: спочатку `1`,потім `2`. | ||
```js run | ||
alert( alert(1) || 2 || alert(3) ); | ||
``` | ||
Виклик`alert`не повертає значення. Або, іншими словами, повертає `undefined`. | ||
1.Перший АБО`||`обчислює його лівий операнд `alert(1)`.Це показує перше повідомлення з `1`. | ||
2. `alert`повертає `undefined`,тому АБО переходить до другого операнда, шукаючи правдиве значення. | ||
3.Другий операнд`2`є правдивим, тому виконання зупинено, повернуто`2`і потім показано зовнішнім alert. | ||
Не буде`3`,тому що обчислення на досягає `alert(3)`. |
4 changes: 2 additions & 2 deletions1-js/02-first-steps/11-logical-operators/2-alert-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
2 changes: 1 addition & 1 deletion1-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,4 +1,4 @@ | ||
Відповідь: `null`,тому що це перше не правдиве значення зі списку. | ||
```js run | ||
alert( 1 && null && 2 ); | ||
4 changes: 2 additions & 2 deletions1-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 |
---|---|---|
@@ -2,9 +2,9 @@ importance: 5 | ||
--- | ||
#Який результат І? | ||
Що виведе код нижче? | ||
```js | ||
alert( 1 && null && 2 ); | ||
6 changes: 3 additions & 3 deletions1-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 @@ | ||
Відповідь: `1`,а потім `undefined`. | ||
```js run | ||
alert( alert(1) && alert(2) ); | ||
``` | ||
Виклик`alert`повертає `undefined` (він просто показує повідомлення, тому не повертається значення, яке б мало сенс). | ||
Через це`&&`обчислює лівий операнд (виводить `1`) і негайно зупиняється, оскільки `undefined`є не правдивим значенням. І `&&`шукає не правдиве значення і повертає його, як це і зроблено. | ||
4 changes: 2 additions & 2 deletions1-js/02-first-steps/11-logical-operators/4-alert-and/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
8 changes: 4 additions & 4 deletions1-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 @@ | ||
Відповідь: `3`. | ||
```js run | ||
alert( null || 2 && 3 || 4 ); | ||
``` | ||
Пріоритет І`&&`вище за`||`,тому він виконується першим. | ||
Результат`2 && 3 = 3`,тому вираз стає: | ||
``` | ||
null || 3 || 4 | ||
``` | ||
Тепер результат — перше правдиве значення: `3`. | ||
4 changes: 2 additions & 2 deletions1-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 |
---|---|---|
@@ -2,9 +2,9 @@ importance: 5 | ||
--- | ||
#Результат АБО І АБО | ||
Який буде результат? | ||
```js | ||
alert( null || 2 && 3 || 4 ); | ||
6 changes: 3 additions & 3 deletions1-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
4 changes: 2 additions & 2 deletions1-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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
Перший варіант: | ||
```js | ||
if (!(age >= 14 && age <= 90)) | ||
``` | ||
Другий варіант: | ||
```js | ||
if (age < 14 || age > 90) | ||
6 changes: 3 additions & 3 deletions1-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
24 changes: 12 additions & 12 deletions1-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 @@ | ||
Відповідь: перший і третій виконаються. | ||
Деталі: | ||
```js run | ||
//Виконається. | ||
//Результат-1 || 0 = -1,правдивий | ||
if (-1 || 0) alert( 'перший' ); | ||
//Не виконається | ||
// -1 && 0 = 0,не правдивий | ||
if (-1 && 0) alert( 'другий' ); | ||
//Виконається | ||
//Оператор &&має більший приорітет, ніж || | ||
//тому -1 && 1виконається першим, даючи нам послідовність: | ||
// null || -1 && 1 -> null || 1 -> 1 | ||
if (null || -1 && 1) alert( 'третій' ); | ||
``` | ||
12 changes: 6 additions & 6 deletions1-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
16 changes: 8 additions & 8 deletions1-js/02-first-steps/11-logical-operators/9-check-login/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,25 +1,25 @@ | ||
```js run demo | ||
let userName = prompt("Хто там?", ''); | ||
if (userName == 'Admin') { | ||
let pass = prompt('Пароль?', ''); | ||
if (pass == 'TheMaster') { | ||
alert( 'Ласкаво просимо!' ); | ||
} else if (pass == '' || pass == null) { | ||
alert( 'Скасовано.' ); | ||
} else { | ||
alert( 'Неправильний пароль' ); | ||
} | ||
} else if (userName == '' || userName == null) { | ||
alert( 'Скасовано' ); | ||
} else { | ||
alert( "Я вас не знаю" ); | ||
} | ||
``` | ||
Зверніть увагу на вертикальні відступи у блоках`if`. Вони технічно не потрібні, але роблять код читабельним. |
20 changes: 10 additions & 10 deletions1-js/02-first-steps/11-logical-operators/9-check-login/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
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
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.