Skip to content

Commit 846cbb1

Browse files
chore: translate basic operators, maths article
Basic operators, maths
2 parents 48abf36 + 89ddea4 commit 846cbb1

File tree

9 files changed

+198
-199
lines changed

9 files changed

+198
-199
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
The answer is:
2+
A resposta é:
33

44
- `a = 2`
55
- `b = 2`
@@ -9,10 +9,10 @@ The answer is:
99
```js run no-beautify
1010
let a = 1, b = 1;
1111

12-
alert( ++a ); // 2, prefix form returns the new value
13-
alert( b++ ); // 1, postfix form returns the old value
12+
alert( ++a ); // 2, a forma prefixa retorna o novo valor
13+
alert( b++ ); // 1, a forma pós-fixa retorna o valor antigo
1414

15-
alert( a ); // 2, incremented once
16-
alert( b ); // 2, incremented once
15+
alert( a ); // 2, incrementado uma vez
16+
alert( b ); // 2, incrementado uma vez
1717
```
1818

1-js/02-first-steps/08-operators/1-increment-order/task.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ importance: 5
22

33
---
44

5-
# The postfix and prefix forms
5+
# Formas pós-fixa e prefixa
66

7-
What are the final values of all variables `a`, `b`, `c` and `d` after the code below?
7+
Quais são os valores finais de todas as variáveis `a`, `b`, `c` e `d` após o código abaixo?
88

99
```js
1010
let a = 1, b = 1;
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
The answer is:
1+
A resposta é:
22

3-
- `a = 4` (multiplied by 2)
4-
- `x = 5` (calculated as 1 + 4)
3+
- `a = 4` (multiplicado por 2)
4+
- `x = 5` (calculado como 1 + 4)
55

1-js/02-first-steps/08-operators/2-assignment-result/task.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ importance: 3
22

33
---
44

5-
# Assignment result
5+
# Resultado da atribuição
66

7-
What are the values of `a` and `x` after the code below?
7+
Quais são os valores de `a` e `x` após o código abaixo?
88

99
```js
1010
let a = 2;

1-js/02-first-steps/08-operators/3-primitive-conversions-questions/solution.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ undefined + 1 = NaN // (6)
1616
" \t \n" - 2 = -2 // (7)
1717
```
1818

19-
1. The addition with a string `"" + 1` converts `1` to a string: `"" + 1 = "1"`, and then we have `"1" + 0`, the same rule is applied.
20-
2. The subtraction `-` (like most math operations) only works with numbers, it converts an empty string `""` to `0`.
21-
3. The addition with a string appends the number `5` to the string.
22-
4. The subtraction always converts to numbers, so it makes `" -9 "` a number `-9` (ignoring spaces around it).
23-
5. `null` becomes `0` after the numeric conversion.
24-
6. `undefined` becomes `NaN` after the numeric conversion.
25-
7. Space characters are trimmed off string start and end when a string is converted to a number. Here the whole string consists of space characters, such as `\t`, `\n` and a "regular" space between them. So, similarly to an empty string, it becomes `0`.
19+
1. A adição de uma string `"" + 1` converte `1` para uma string: `"" + 1 = "1"`, e quando nós temos `"1" + 0`, a mesma regra é aplicada.
20+
2. A subtração `-` (como a maioria das operações matemáticas) apenas funciona com números, e converte uma string vazia `""` para `0`.
21+
3. A adição a uma string anexa o número `5` à string.
22+
4. A subtração sempre converte para números, de modo que esta transforma `" -9 "` no número `-9` (ignorando os espaços em volta deste).
23+
5. `null` se torna `0` após a conversão numérica.
24+
6. `undefined` se torna `NaN` após a conversão numérica.
25+
7. Caracteres de espaço, são aparados do início e final de uma string quando esta é convertida em um número. Aqui a string inteira consiste em caracteres de espaço, tais como `\t`, `\n` e um espaço "regular" entre eles. Então, similarmente à string vazia, isto se torna `0`.

1-js/02-first-steps/08-operators/3-primitive-conversions-questions/task.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ importance: 5
22

33
---
44

5-
# Type conversions
5+
# Conversões de tipo
66

7-
What are results of these expressions?
7+
Quais são os resultados destas expressões?
88

99
```js no-beautify
1010
"" + 1 + 0
@@ -23,4 +23,4 @@ undefined + 1
2323
" \t \n" - 2
2424
```
2525

26-
Think well, write down and then compare with the answer.
26+
Pense bem, escreva e então compare com a resposta.
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
1-
The reason is that prompt returns user input as a string.
1+
A razão é que o prompt retorna o input do usuário como uma string.
22

3-
So variables have values `"1"` and `"2"` respectively.
3+
Então as variáveis têm valores `"1"` e `"2"`, respectivamente.
44

55
```js run
6-
let a = "1"; // prompt("First number?", 1);
7-
let b = "2"; // prompt("Second number?", 2);
6+
let a = "1"; // prompt("Primeiro número?", 1);
7+
let b = "2"; // prompt("Segundo número?", 2);
88

99
alert(a + b); // 12
1010
```
1111

12-
What we should do is to convert strings to numbers before `+`. For example, using `Number()` or prepending them with `+`.
12+
O que nós devemos fazer é converter strings em números antes da adição (`+`). Por exemplo, usando `Number()` ou precedendo-os com `+`.
1313

14-
For example, right before `prompt`:
14+
Por exemplo, logo antes do `prompt`:
1515

1616
```js run
17-
let a = +prompt("First number?", 1);
18-
let b = +prompt("Second number?", 2);
17+
let a = +prompt("Primeiro número?", 1);
18+
let b = +prompt("Segundo número?", 2);
1919

2020
alert(a + b); // 3
2121
```
2222

23-
Or in the `alert`:
23+
Ou no `alert`:
2424

2525
```js run
26-
let a = prompt("First number?", 1);
27-
let b = prompt("Second number?", 2);
26+
let a = prompt("Primeiro número?", 1);
27+
let b = prompt("Segundo número?", 2);
2828

2929
alert(+a + +b); // 3
3030
```
3131

32-
Using both unary and binary `+` in the latest code. Looks funny, doesn't it?
32+
Usando ambos `+` unário e binário no último código. Parece engraçado, não é mesmo?

1-js/02-first-steps/08-operators/4-fix-prompt/task.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@ importance: 5
22

33
---
44

5-
# Fix the addition
5+
# Conserte a adição
66

7-
Here's a code that asks the user for two numbers and shows their sum.
7+
Aqui está um código que pede dois números ao usuário e mostra a soma dos mesmos.
88

9-
It works incorrectly. The output in the example below is `12` (for default prompt values).
9+
Ele funciona incorretamente. A saída no exemplo abaixo é `12` (para os valores presentes por padrão no prompt, definidos pelo segundo argumento).
1010

11-
Why? Fix it. The result should be `3`.
11+
Por quê? Conserte isto. O resultado deveria ser `3`.
1212

1313
```js run
14-
let a = prompt("First number?", 1);
15-
let b = prompt("Second number?", 2);
14+
let a = prompt("Primeiro número?", 1);
15+
let b = prompt("Segundo número?", 2);
1616

1717
alert(a + b); // 12
1818
```

0 commit comments

Comments
 (0)