-
Notifications
You must be signed in to change notification settings - Fork 31
Logical operators #185
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
Logical operators #185
Changes from 21 commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
aaf2254
article translation
Cr3yZe 111c08e
translating to line 38. articel.md: logival-operators
Cr3yZe 3c92cb3
translation to line 126
Cr3yZe ae84619
translation to the line 141
Cr3yZe f543570
translated: logical-operators> articel.md to line 191
Cr3yZe aa45929
translated: logical-operators> articel.md to line 206
Cr3yZe 43565c1
11-logical-operators finish translation for article.md
Cr3yZe 5531ae1
small change
Cr3yZe a0d0439
1-alert-null-2-undefined finish translation
Cr3yZe ad93b73
2-alert-or finish translation
Cr3yZe 47660e7
3-alert-1-null-2 finish translation
Cr3yZe 1e59490
4-alert-and finish translation
Cr3yZe 086f192
5-alert-and-or finish translation
Cr3yZe ecc1875
6-check-if-in-range finish translation
Cr3yZe 4158952
7-check-if-out-range
Cr3yZe 35dda72
small corection
Cr3yZe 9cd16a4
8-if-question finish translation
Cr3yZe 24572f0
9-check-login finish translation
Cr3yZe 3af9522
11-logical-operator article.md checking mistakes
Cr3yZe d35c1d2
11-logical-operators checking mistakes in tasks folders
Cr3yZe 4052b6c
Merge branch 'javascript-tutorial:master' into translation
Cr3yZe 4cb2e1a
implementing the changes requested
Cr3yZe 0428881
reviewing article and tasks
Cr3yZe 3a545ea
Merge branch 'translation' of github.com:Cr3yZe/ro.javascript.info in…
Cr3yZe 6be161a
task 4 solution minor fix
bogdanbacosca 1ff779d
task 6 minor fix
bogdanbacosca a7b86ac
task 8 minor fix
bogdanbacosca 1475c22
task 9 minor fixes
bogdanbacosca f94deca
minor fixes
bogdanbacosca 13c6cb8
other fixes
bogdanbacosca eb6f7e4
minor fixes
bogdanbacosca 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
2 changes: 1 addition & 1 deletion
2
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
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`. | ||
Răspunsul este: prima dată `1`, iar apoi `2`. | ||
Cr3yZe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
```js run | ||
alert( alert(1) || 2 || alert(3) ); | ||
``` | ||
|
||
The call to `alert` does not return a value. Or, in other words, it returns `undefined`. | ||
Metoda `alert` nu returnează o valoare. Prin alte cuvinte, returnează `undefined`. | ||
Cr3yZe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
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. Primul ORI `||` evaluează operantul din stânga sa `alert(1)`. Acesta afișează primul mesaj cu `1`. | ||
Cr3yZe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
2. `alert` întoarce `undefined`, prin urmare, ORI merge la cel de al doilea operant, deaorece caută o valoare truthy. | ||
Cr3yZe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
3. Cel de al doilea operant `2` este truthy, așa că execuția este oprită, `2` este returnat fiind afișat de către `alert`-ul exterior. | ||
Cr3yZe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
There will be no `3`, because the evaluation does not reach `alert(3)`. | ||
`3` nu va fi afișat, deoarece evaluarea nu ajunge la `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
7 changes: 3 additions & 4 deletions
7
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,9 @@ | ||
The answer: `1`, and then `undefined`. | ||
Răspunsul: `1`, iar apoi `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). | ||
|
||
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. | ||
Metoda `alert` întoarce `undefined` (afișează doar un mesaj, deci nu întoarce nimic semnificativ). | ||
|
||
Din cauza aceasta, `&&` evaluează operantul din stânga (output-ul `1`), și oprește imediat evaluarea, deoarece `undefined` este o valoare falsy. `&&` caută o valoare falsy și o întoarce, așadar procesul este finalizat. |
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
9 changes: 4 additions & 5 deletions
9
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,15 @@ | ||
The answer: `3`. | ||
Răspunsul este: `3` | ||
Cr3yZe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
```js run | ||
alert( null || 2 && 3 || 4 ); | ||
``` | ||
|
||
The precedence of AND `&&` is higher than `||`, so it executes first. | ||
Prioritatea lui ȘI `&&` este mai mare decât cea a lui ORI `||`, așa că `&&` executat primul. | ||
Cr3yZe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
The result of `2 && 3 = 3`, so the expression becomes: | ||
Rezultatul lui `2 && 3 = 3`, așa că expresia devine: | ||
|
||
``` | ||
null || 3 || 4 | ||
``` | ||
|
||
Now the result is the first truthy value: `3`. | ||
|
||
În acest caz, rezultatul este prima valoare truthy: `3`. | ||
Cr3yZe marked this conversation as resolved.
Show resolved
Hide resolved
|
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
22 changes: 11 additions & 11 deletions
22
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. | ||
Răspuns: primul și al treilea vor fi afișate. | ||
Cr3yZe marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
Details: | ||
Detalii: | ||
|
||
```js run | ||
// Runs. | ||
// The result of -1 || 0 = -1, truthy | ||
if (-1 || 0) alert( 'first' ); | ||
// Este executat. | ||
// Rezultatul dintre -1 || 0 = -1, truthy | ||
if (-1 || 0) alert( 'primul' ); | ||
|
||
// Doesn't run | ||
// Nu este executat | ||
// -1 && 0 = 0, falsy | ||
if (-1 && 0) alert( 'second' ); | ||
if (-1 && 0) alert( 'al doilea' ); | ||
|
||
// Executes | ||
// Operator && has a higher precedence than || | ||
// so -1 && 1 executes first, giving us the chain: | ||
// Este executat | ||
// Oparatorul && are o prioritate mai mare decât || | ||
// așadar -1 && 1 este exuctat mai întâi, dând lanțul următor: | ||
// null || -1 && 1 -> null || 1 -> 1 | ||
if (null || -1 && 1) alert( 'third' ); | ||
if (null || -1 && 1) alert( 'al treilea' ); | ||
``` | ||
|
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
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.