Skip to content

Commit 3d2e604

Browse files
author
Casian Todor
committed
1-js/02-first-steps/11-logical-operators
1 parent a407eef commit 3d2e604

File tree

14 files changed

+115
-124
lines changed

14 files changed

+115
-124
lines changed

1-js/02-first-steps/11-logical-operators/1-alert-null-2-undefined/solution.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
The answer is `2`, that's the first truthy value.
1+
Răspunsul este `2`, aceasta este prima valoare truthy.
22

33
```js run
44
alert( null || 2 || undefined );

1-js/02-first-steps/11-logical-operators/1-alert-null-2-undefined/task.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
importance: 5
1+
importanță: 5
22

33
---
44

5-
# What's the result of OR?
5+
# Care este rezultatul lui OR?
66

7-
What is the code below going to output?
7+
Ce va afișa codul de mai jos?
88

99
```js
1010
alert( null || 2 || undefined );
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
The answer: first `1`, then `2`.
1+
Răspunsul: prima dată `1`, apoi `2`.
22

33
```js run
44
alert( alert(1) || 2 || alert(3) );
55
```
66

7-
The call to `alert` does not return a value. Or, in other words, it returns `undefined`.
7+
Apelul lui `alert` nu returnează o valoare. Sau, cu alte cuvinte, returnează `undefined`.
88

9-
1. The first OR `||` evaluates it's left operand `alert(1)`. That shows the first message with `1`.
10-
2. The `alert` returns `undefined`, so OR goes on to the second operand searching for a truthy value.
11-
3. The second operand `2` is truthy, so the execution is halted, `2` is returned and then shown by the outer alert.
9+
1. Primul OR `||` evaluează operandul său din stânga `alert(1)`. Aceasta arată primul mesaj cu `1`.
10+
2. `alert` returnează `undefined`, așadar OR merge către cel de al doilea operand și se uită după o valoare truthy.
11+
3. Al doilea operator `2` este truthy, așa că execuția este oprită, se returnează `2` și apoi este afișat de alert-ul din afară.
1212

13-
There will be no `3`, because the evaluation does not reach `alert(3)`.
13+
Nu va exista niciun `3`, pentru că evaluarea nu ajunge la `alert(3)`.

1-js/02-first-steps/11-logical-operators/3-alert-1-null-2/solution.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
The answer: `null`, because it's the first falsy value from the list.
1+
Răspunsul: `null`, pentru că este prima valoare falsy din listă.
22

33
```js run
44
alert( 1 && null && 2 );

1-js/02-first-steps/11-logical-operators/3-alert-1-null-2/task.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
importance: 5
1+
importanță: 5
22

33
---
44

5-
# What is the result of AND?
5+
# Care este rezultatul lui AND?
66

7-
What is this code going to show?
7+
Ce va afișa codul?
88

99
```js
1010
alert( 1 && null && 2 );
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
The answer: `1`, and then `undefined`.
1+
Răspunsul: `1`, și apoi `undefined`.
22

33
```js run
44
alert( alert(1) && alert(2) );
55
```
66

7-
The call to `alert` returns `undefined` (it just shows a message, so there's no meaningful return).
8-
9-
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.
7+
Apelul lui `alert` returnează `undefined` (doar afișează un mesaj, așa că nu este un return semnificativ).
108

9+
Din această cauză, `&&` evaluează operandul stâng (returnează `1`) și apoi se oprește imediat, pentru că `undefined` este o valoare falsy. Iar `&&` caută o valoare falsy și o returnează, și gata.
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
1-
The answer: `3`.
1+
Răspunsul: `3`.
22

33
```js run
44
alert( null || 2 && 3 || 4 );
55
```
6+
Precedența lui AND `&&` este mai mare decât `||`, așa că execută primul.
67

7-
The precedence of AND `&&` is higher than `||`, so it executes first.
8-
9-
The result of `2 && 3 = 3`, so the expression becomes:
8+
Rezultatul este `2 && 3 = 3`, așa că expresia devine:
109

1110
```
1211
null || 3 || 4
1312
```
1413

15-
Now the result is the first truthy value: `3`.
16-
14+
Acum rezultatul este prima valoare truthy: `3`.
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
importance: 5
1+
importanță: 5
22

33
---
44

5-
# The result of OR AND OR
5+
# Rezultatul lui OR AND OR
66

7-
What will the result be?
7+
Care va fi rezultatul?
88

99
```js
1010
alert( null || 2 && 3 || 4 );
11-
```
12-
11+
```
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
importance: 3
1+
importanță: 3
22

33
---
44

5-
# Check the range between
5+
# Verifică intervalul din mijloc
66

7-
Write an "if" condition to check that `age` is between `14` and `90` inclusively.
7+
Scrie o condiție "if" pentru a verifica că `age` este între `14` și `90`, inclusiv.
88

9-
"Inclusively" means that `age` can reach the edges `14` or `90`.
9+
"Inclusiv" înseamnă că `age` poate ajunge și la capetele `14` sau `90`.
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
The first variant:
1+
Prima variantă:
22

33
```js
44
if (!(age >= 14 && age <= 90))
55
```
66

7-
The second variant:
7+
A doua variantă:
88

99
```js
1010
if (age < 14 || age > 90)
11-
```
12-
11+
```

0 commit comments

Comments
 (0)