Skip to content

Commit 33f3ea4

Browse files
Merge pull request #314 from ezzep66/math-basic-operators
Basic operators, maths
2 parents ef97645 + ec1088a commit 33f3ea4

File tree

9 files changed

+178
-179
lines changed

9 files changed

+178
-179
lines changed
Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
The answer is:
2+
La respuesta es:
33

44
- `a = 2`
55
- `b = 2`
@@ -9,10 +9,9 @@ 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, la forma de prefijo devuelve el nuevo valor
13+
alert( b++ ); // 1, la forma de sufijo devuelve el antiguo valor
1414

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

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ importance: 5
22

33
---
44

5-
# The postfix and prefix forms
5+
# Las formas sufijo y prefijo
66

7-
What are the final values of all variables `a`, `b`, `c` and `d` after the code below?
7+
¿Cuáles son los valores finales de todas las variables `a`, `b`, `c` y `d` después del código a continuación?
88

99
```js
1010
let a = 1, b = 1;
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
The answer is:
1+
La respuesta es:
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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ importance: 3
22

33
---
44

5-
# Assignment result
5+
# Resultado de asignación
66

7-
What are the values of `a` and `x` after the code below?
7+
¿Cuáles son los valores de 'a' y 'x' después del código a continuación?
88

99
```js
1010
let a = 2;

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ undefined + 1 = NaN // (6)
1717
" \t \n" - 2 = -2 // (7)
1818
```
1919

20-
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.
21-
2. The subtraction `-` (like most math operations) only works with numbers, it converts an empty string `""` to `0`.
22-
3. The addition with a string appends the number `5` to the string.
23-
4. The subtraction always converts to numbers, so it makes `" -9 "` a number `-9` (ignoring spaces around it).
24-
5. `null` becomes `0` after the numeric conversion.
25-
6. `undefined` becomes `NaN` after the numeric conversion.
26-
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`.
20+
1. La suma con una cadena `"" + 1` convierte `1` a un string: `"" + 1 = "1"`, y luego tenemos `"1" + 0`, la misma regla se aplica.
21+
2. La resta `-` (como la mayoría de las operaciones matemáticas) sólo funciona con números, convierte una cadena vacía `""` a `0`.
22+
3. La suma con una cadena concatena el número `5` a la cadena.
23+
4. La resta siempre convierte a números, por lo tanto hace de `" -9 "` un número `-9` (ignorando los espacios que lo rodean).
24+
5. `null` se convierte en `0` después de la conversión numérica.
25+
6. `undefined` se convierte en `NaN` después de la conversión numérica.
26+
7. Los caracteres de espacio se recortan al inicio y al final de la cadena cuando una cadena se convierte en un número. Aquí toda la cadena consiste en caracteres de espacio, tales como `\t`, `\n` y un espacio "común" entre ellos. Por lo tanto, pasa lo mismo que a una cadena vacía, se convierte en `0`.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ importance: 5
22

33
---
44

5-
# Conversiones de Tipos
5+
# Conversiones de tipos
66

77
¿Cuáles son los resultados de estas expresiones?
88

@@ -24,4 +24,4 @@ undefined + 1
2424
" \t \n" - 2
2525
```
2626

27-
Piensa cuidadosamente, luego escribe los resultados y compáralos con la respuesta.
27+
Piensa bien, anótalos y luego compara con la respuesta.
Lines changed: 12 additions & 12 deletions
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+
La razón es que la captura devuelve la entrada del usuario como una cadena.
22

3-
So variables have values `"1"` and `"2"` respectively.
3+
Entonces las variables tienen valores `"1"` y `"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("Primer número?", 1);
7+
let b = "2"; // prompt("Segundo número?", 2);
88

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

12-
What we should to is to convert strings to numbers before `+`. For example, using `Number()` or prepending them with `+`.
12+
Lo que debemos hacer es convertir las cadenas de texto a números antes `+`. Por ejemplo, utilizando `Number()` o anteponiendo `+`.
1313

14-
For example, right before `prompt`:
14+
Por ejemplo, justo antes de `prompt`:
1515

1616
```js run
17-
let a = +prompt("First number?", 1);
18-
let b = +prompt("Second number?", 2);
17+
let a = +prompt("Primer 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+
O en el `alert`:
2424

2525
```js run
26-
let a = prompt("First number?", 1);
27-
let b = prompt("Second number?", 2);
26+
let a = prompt("Primer 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+
Usar ambos unario y binario `+` en el último ejemplo, se ve raro no?

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@ importance: 5
22

33
---
44

5-
# Fix the addition
5+
# Corregir la adición
66

7-
Here's a code that asks the user for two numbers and shows their sum.
7+
Aquí hay un código que le pide al usuario dos números y muestra su suma.
88

9-
It works incorrectly. The output in the example below is `12` (for default prompt values).
9+
Funciona incorrectamente. El resultado en el ejemplo a continuación es `12` (para valores de captura predeterminados).
1010

11-
Why? Fix it. The result should be `3`.
11+
¿Por qué? Arreglalo. El resultado debería ser `3`.
1212

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

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

0 commit comments

Comments
 (0)