Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork3
Logical operators#77
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
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
40a4866
1.2.11
otmon763fad7ec
Update 1-js/02-first-steps/11-logical-operators/article.md
otmon7602780ea
Update 1-js/02-first-steps/11-logical-operators/6-check-if-in-range/t…
otmon76a60e98f
Update 1-js/02-first-steps/11-logical-operators/9-check-login/task.md
otmon76b062374
Update 1-js/02-first-steps/11-logical-operators/9-check-login/task.md
otmon76ab291f2
Update 1-js/02-first-steps/11-logical-operators/9-check-login/task.md
otmon7678f1df5
Update 1-js/02-first-steps/11-logical-operators/9-check-login/task.md
otmon76474789e
Update 1-js/02-first-steps/11-logical-operators/9-check-login/solutio…
otmon76017bd68
Update 1-js/02-first-steps/11-logical-operators/9-check-login/solutio…
otmon76970cbed
Update 1-js/02-first-steps/11-logical-operators/9-check-login/solutio…
otmon76File 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 @@ | ||
Odpověď zní`2`,což je první pravdivá hodnota. | ||
```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 | ||
--- | ||
#Jaký je výsledek OR? | ||
Co vypíše níže uvedený kód? | ||
```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 @@ | ||
Odpověď zní: nejprve `1`,pak `2`. | ||
```js run | ||
alert( alert(1) || 2 || alert(3) ); | ||
``` | ||
Volání`alert`nevrátí žádnou hodnotu, jinými slovy vrátí `undefined`. | ||
1.PrvníOR `||`vyhodnotí svůj levý operand `alert(1)`.Ten zobrazí první zprávu obsahující `1`. | ||
2.Tento `alert`vrátí `undefined`,takže ORve svém hledání pravdivé hodnoty přejde ke druhému operandu. | ||
3.Druhýoperand `2`je pravdivý, takže vyhodnocení operátoru se zastaví, vrátí`2`a to je pak zobrazeno vnějším `alert`em. | ||
Nezobrazí se`3`,protože vyhodnocení se k`alert(3)` nedostane. |
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 @@ | ||
Odpověď zní `null`,protože je to první nepravdivá hodnota v seznamu. | ||
```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 | ||
--- | ||
#Jaký je výsledek AND? | ||
Co vypíše níže uvedený kód? | ||
```js | ||
alert( 1 && null && 2 ); | ||
7 changes: 3 additions & 4 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,9 @@ | ||
Odpověď zní: nejprve`1`,pak `undefined`. | ||
```js run | ||
alert( alert(1) && alert(2) ); | ||
``` | ||
Volání `alert` vrátí `undefined` (funkce jen zobrazí zprávu, takže její návratová hodnota nemá žádný význam). | ||
Proto `&&` vyhodnotí první operand (vypíše `1`) a okamžitě se zastaví, protože `undefined` je nepravdivá hodnota. Operátor `&&` hledá první nepravdivou hodnotu a vrátí ji, takže je hotov. |
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 @@ | ||
Odpověď zní: `3`. | ||
```js run | ||
alert( null || 2 && 3 || 4 ); | ||
``` | ||
OperátorAND `&&`má vyšší prioritu než`||`,proto se vykoná jako první. | ||
Výsledek`2 && 3 = 3`,takže z výrazu se stane: | ||
``` | ||
null || 3 || 4 | ||
``` | ||
Nyní bude výsledkem první pravdivá hodnota: `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 | ||
--- | ||
#Výsledek OR AND OR | ||
Jaký bude výsledek? | ||
```js | ||
alert( null || 2 && 3 || 4 ); | ||
2 changes: 1 addition & 1 deletion1-js/02-first-steps/11-logical-operators/6-check-if-in-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,6 +1,6 @@ | ||
```js | ||
if (věk >= 14 &&věk <= 90) | ||
``` | ||
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
8 changes: 4 additions & 4 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,12 +1,12 @@ | ||
První varianta: | ||
```js | ||
if (!(věk >= 14 &&věk <= 90)) | ||
``` | ||
Druhá varianta: | ||
```js | ||
if (věk < 14 ||věk > 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 @@ | ||
Odpověď zní: vykoná se první a třetí `alert`. | ||
Podrobnosti: | ||
```js run | ||
//Vykoná se. | ||
//Výsledek-1 || 0 = -1,tedy pravda. | ||
if (-1 || 0) alert( 'první' ); | ||
//Nevykoná se. | ||
// -1 && 0 = 0,nepravda. | ||
if (-1 && 0) alert( 'druhý' ); | ||
//Vykoná se. | ||
//Operátor &&má vyšší prioritu než ||, | ||
//takže -1 && 1se vykoná jako první, což dává tento řetězec: | ||
// null || -1 && 1 -> null || 1 -> 1 | ||
if (null || -1 && 1) alert( 'třetí' ); | ||
``` | ||
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
2 changes: 1 addition & 1 deletion1-js/02-first-steps/11-logical-operators/9-check-login/ifelse_task.svg
Loading
Sorry, something went wrong.Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 12 additions & 12 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 | ||
letuživatelskéJméno = prompt("Kdo je tam?", ''); | ||
if (uživatelskéJméno === 'Správce') { | ||
letheslo = prompt('Heslo?', ''); | ||
if (heslo === 'Vládce') { | ||
alert( 'Vítáme vás!' ); | ||
} else if (heslo === '' ||heslo === null) { | ||
alert( 'Zrušeno' ); | ||
} else { | ||
alert( 'Špatné heslo' ); | ||
} | ||
} else if (uživatelskéJméno === '' ||uživatelskéJméno === null) { | ||
alert( 'Zrušeno' ); | ||
} else { | ||
alert( "Neznám vás" ); | ||
} | ||
``` | ||
Všimněte si svislého odsazení uvnitř bloků `if`. Není technicky vyžadováno, ale činí kód čitelnějším. |
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.