Skip to content

Commit 02f7bd3

Browse files
committed
Translate the tasks and solutions
1 parent 7a982ad commit 02f7bd3

File tree

18 files changed

+80
-90
lines changed

18 files changed

+80
-90
lines changed
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
The answer is `2`, that's the first truthy value.
1+
A resposta é `2`, que é o primeiro valor verdadeiro.
22

33
```js run
44
alert( null || 2 || undefined );
55
```
6-
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
importance: 5
1+
importância: 5
22

33
---
44

5-
# What's the result of OR?
5+
# Qual o resultado do OU?
66

7-
What is the code below going to output?
7+
Qual é a saída do código abaixo?
88

99
```js
1010
alert( null || 2 || undefined );
1111
```
12-
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
The answer: first `1`, then `2`.
2+
A resposta: primeiro `1`, depois `2`.
23

34
```js run
45
alert( alert(1) || 2 || alert(3) );
56
```
67

7-
The call to `alert` does not return a value. Or, in other words, it returns `undefined`.
8+
Ao chamar `alert` não é retornado nenhum valor. Ou seja, é retornado `undefined`.
89

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.
10+
1. O primeiro OU `||` avalia o operando da esquerda `alert(1)`. Que mostra a primeira mensagem com `1`.
11+
2. O `alert` retorna `undefined`, então OU vai ao segundo operando procurando por um valor verdadeiro.
12+
3. O segundo operando `2` é verdadeiro, então a execução é interrompida, `2` é retornado e é mostrado pelo `alert` externo.
1213

13-
There will be no `3`, because the evaluation does not reach `alert(3)`.
14+
Não haverá `3`, pois a execução não chega a `alert(3)`.
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
importance: 3
1+
importância: 3
22

33
---
44

5-
# What's the result of OR'ed alerts?
5+
# Qual o resultado do alerta de encadeamento de OU's?
66

7-
What will the code below output?
7+
Qual a saída do código abaixo?
88

99
```js
1010
alert( alert(1) || 2 || alert(3) );
1111
```
12-
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
The answer: `null`, because it's the first falsy value from the list.
1+
Resposta: `null`, pois é o primeiro valor falso da lista.
22

33
```js run
44
alert( 1 && null && 2 );
55
```
6-
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
importance: 5
1+
importância: 5
22

33
---
44

5-
# What is the result of AND?
5+
# Qual o resultado de E?
66

7-
What is this code going to show?
7+
O que este código irá mostrar?
88

99
```js
1010
alert( 1 && null && 2 );
1111
```
12-
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
The answer: `1`, and then `undefined`.
2+
Resposta: `1`, e depois `undefined`.
23

34
```js run
45
alert( alert(1) && alert(2) );
56
```
67

78
The call to `alert` returns `undefined` (it just shows a message, so there's no meaningful return).
9+
A chamada de `alert` retorna `undefined` (apenas mostra uma mensagem, então não existe nenhum retorno significativo).
810

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.
10-
11+
Por causa disso, `&&` avalia o operando à esquerda (mostra `1`), e imediatamente interrompe, pois `undefined` é um valor falso. E `&&` procura por um valor falso e o retorna, então está feito.
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
importance: 3
1+
importância: 3
22

33
---
44

5-
# What is the result of AND'ed alerts?
5+
# Qual o resultado dos alerts encadeados em E?
66

7-
What will this code show?
7+
O que este código irá mostrar?
88

99
```js
1010
alert( alert(1) && alert(2) );
1111
```
12-
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
The answer: `3`.
1+
Resposta: `3`.
22

33
```js run
44
alert( null || 2 && 3 || 4 );
55
```
66

7-
The precedence of AND `&&` is higher than `||`, so it executes first.
7+
A precedência de E `&&` é maior do que OU `||`. então ele é executado primeiro.
88

9-
The result of `2 && 3 = 3`, so the expression becomes:
9+
O resultado de `2 && 3 = 3`, então a expressão se torna:
1010

1111
```
1212
null || 3 || 4
1313
```
1414

15-
Now the result is the first truthy value: `3`.
16-
15+
Agora o resultado é o primeiro valor verdadeiro: `3`.
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
importance: 5
1+
importância: 5
22

33
---
44

5-
# The result of OR AND OR
5+
# O resultado de OR E OR
66

7-
What will the result be?
7+
Qual será o resultado?
88

99
```js
1010
alert( null || 2 && 3 || 4 );
1111
```
12-

0 commit comments

Comments
 (0)