chore(i8n,learn): processed translations (#41433)
Co-authored-by: Crowdin Bot <support+bot@crowdin.com>
This commit is contained in:
@ -26,7 +26,7 @@ En orden, estas expresiones se evaluarían como `true`, `true`, `false` y `false
|
||||
|
||||
# --instructions--
|
||||
|
||||
Agrega el operador "mayor que" a las líneas indicadas para que las declaraciones de devolución tengan sentido.
|
||||
Agrega el operador mayor que a las líneas indicadas para que las declaraciones de devolución tengan sentido.
|
||||
|
||||
# --hints--
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244d6
|
||||
title: Comparison with the Less Than Operator
|
||||
title: Comparación con el operador "menor que"
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/cNVRWtB'
|
||||
forumTopicId: 16789
|
||||
@ -9,61 +9,63 @@ dashedName: comparison-with-the-less-than-operator
|
||||
|
||||
# --description--
|
||||
|
||||
The <dfn>less than</dfn> operator (`<`) compares the values of two numbers. If the number to the left is less than the number to the right, it returns `true`. Otherwise, it returns `false`. Like the equality operator, <dfn>less than</dfn> operator converts data types while comparing.
|
||||
El operador <dfn>menor que</dfn> (`<`) compara los valores de dos números. Si el número a la izquierda es menor que el número a la derecha, devuelve `true`. De lo contrario, devuelve `false`. Al igual que el operador de igualdad, el operador <dfn>menor que</dfn> convertirá los tipos de datos mientras los compara.
|
||||
|
||||
**Examples**
|
||||
**Ejemplos**
|
||||
|
||||
```js
|
||||
2 < 5 // true
|
||||
'3' < 7 // true
|
||||
5 < 5 // false
|
||||
3 < 2 // false
|
||||
'8' < 4 // false
|
||||
2 < 5
|
||||
'3' < 7
|
||||
5 < 5
|
||||
3 < 2
|
||||
'8' < 4
|
||||
```
|
||||
|
||||
En orden, estas expresiones se evaluarían como `true`, `true`, `false`, `false` y `false`.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Add the less than operator to the indicated lines so that the return statements make sense.
|
||||
Agrega el operador menor que a las líneas indicadas para que las declaraciones de devolución tengan sentido.
|
||||
|
||||
# --hints--
|
||||
|
||||
`testLessThan(0)` should return "Under 25"
|
||||
`testLessThan(0)` debe devolver la cadena `Under 25`
|
||||
|
||||
```js
|
||||
assert(testLessThan(0) === 'Under 25');
|
||||
```
|
||||
|
||||
`testLessThan(24)` should return "Under 25"
|
||||
`testLessThan(24)` debe devolver la cadena `Under 25`
|
||||
|
||||
```js
|
||||
assert(testLessThan(24) === 'Under 25');
|
||||
```
|
||||
|
||||
`testLessThan(25)` should return "Under 55"
|
||||
`testLessThan(25)` debe devolver la cadena `Under 55`
|
||||
|
||||
```js
|
||||
assert(testLessThan(25) === 'Under 55');
|
||||
```
|
||||
|
||||
`testLessThan(54)` should return "Under 55"
|
||||
`testLessThan(54)` debe devolver la cadena `Under 55`
|
||||
|
||||
```js
|
||||
assert(testLessThan(54) === 'Under 55');
|
||||
```
|
||||
|
||||
`testLessThan(55)` should return "55 or Over"
|
||||
`testLessThan(55)` debe devolver la cadena `55 or Over`
|
||||
|
||||
```js
|
||||
assert(testLessThan(55) === '55 or Over');
|
||||
```
|
||||
|
||||
`testLessThan(99)` should return "55 or Over"
|
||||
`testLessThan(99)` debe devolver la cadena `55 or Over`
|
||||
|
||||
```js
|
||||
assert(testLessThan(99) === '55 or Over');
|
||||
```
|
||||
|
||||
You should use the `<` operator at least twice
|
||||
Debes usar el operador `<` por lo menos dos veces
|
||||
|
||||
```js
|
||||
assert(code.match(/val\s*<\s*('|")*\d+('|")*/g).length > 1);
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244d7
|
||||
title: Comparison with the Less Than Or Equal To Operator
|
||||
title: Comparación con el operador "menor o igual que"
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/cNVR7Am'
|
||||
forumTopicId: 16788
|
||||
@ -9,67 +9,69 @@ dashedName: comparison-with-the-less-than-or-equal-to-operator
|
||||
|
||||
# --description--
|
||||
|
||||
The less than or equal to operator (`<=`) compares the values of two numbers. If the number to the left is less than or equal to the number to the right, it returns `true`. If the number on the left is greater than the number on the right, it returns `false`. Like the equality operator, `less than or equal to` converts data types.
|
||||
El operador menor o igual que (`<=`) compara el valor de dos números. Si el número de la izquierda es menor o igual que el número de la derecha, devuelve `true`. Si el número a la izquierda es mayor que el número a la derecha, devuelve `false`. Al igual que el operador de igualdad, el operador menor o igual que convierte los tipos de datos.
|
||||
|
||||
**Examples**
|
||||
**Ejemplos**
|
||||
|
||||
```js
|
||||
4 <= 5 // true
|
||||
'7' <= 7 // true
|
||||
5 <= 5 // true
|
||||
3 <= 2 // false
|
||||
'8' <= 4 // false
|
||||
4 <= 5
|
||||
'7' <= 7
|
||||
5 <= 5
|
||||
3 <= 2
|
||||
'8' <= 4
|
||||
```
|
||||
|
||||
En orden, estas expresiones se evaluarían como `true`, `true`, `true`, `false` y `false`.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Add the less than or equal to operator to the indicated lines so that the return statements make sense.
|
||||
Agrega el operador menor o igual que a las líneas indicadas para que el valor devuelto tenga sentido.
|
||||
|
||||
# --hints--
|
||||
|
||||
`testLessOrEqual(0)` should return "Smaller Than or Equal to 12"
|
||||
`testLessOrEqual(0)` debe devolver la cadena `Smaller Than or Equal to 12`
|
||||
|
||||
```js
|
||||
assert(testLessOrEqual(0) === 'Smaller Than or Equal to 12');
|
||||
```
|
||||
|
||||
`testLessOrEqual(11)` should return "Smaller Than or Equal to 12"
|
||||
`testLessOrEqual(11)` debe devolver la cadena `Smaller Than or Equal to 12`
|
||||
|
||||
```js
|
||||
assert(testLessOrEqual(11) === 'Smaller Than or Equal to 12');
|
||||
```
|
||||
|
||||
`testLessOrEqual(12)` should return "Smaller Than or Equal to 12"
|
||||
`testLessOrEqual(12)` debe devolver la cadena `Smaller Than or Equal to 12`
|
||||
|
||||
```js
|
||||
assert(testLessOrEqual(12) === 'Smaller Than or Equal to 12');
|
||||
```
|
||||
|
||||
`testLessOrEqual(23)` should return "Smaller Than or Equal to 24"
|
||||
`testLessOrEqual(23)` debe devolver la cadena `Smaller Than or Equal to 24`
|
||||
|
||||
```js
|
||||
assert(testLessOrEqual(23) === 'Smaller Than or Equal to 24');
|
||||
```
|
||||
|
||||
`testLessOrEqual(24)` should return "Smaller Than or Equal to 24"
|
||||
`testLessOrEqual(24)` debe devolver la cadena `Smaller Than or Equal to 24`
|
||||
|
||||
```js
|
||||
assert(testLessOrEqual(24) === 'Smaller Than or Equal to 24');
|
||||
```
|
||||
|
||||
`testLessOrEqual(25)` should return "More Than 24"
|
||||
`testLessOrEqual(25)` debe devolver la cadena `More Than 24`
|
||||
|
||||
```js
|
||||
assert(testLessOrEqual(25) === 'More Than 24');
|
||||
```
|
||||
|
||||
`testLessOrEqual(55)` should return "More Than 24"
|
||||
`testLessOrEqual(55)` debe devolver la cadena `More Than 24`
|
||||
|
||||
```js
|
||||
assert(testLessOrEqual(55) === 'More Than 24');
|
||||
```
|
||||
|
||||
You should use the `<=` operator at least twice
|
||||
Debes utilizar el operador `<=` al menos dos veces
|
||||
|
||||
```js
|
||||
assert(code.match(/val\s*<=\s*('|")*\d+('|")*/g).length > 1);
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244d1
|
||||
title: Comparison with the Strict Equality Operator
|
||||
title: Comparación con el operador de estricta igualdad
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/cy87atr'
|
||||
forumTopicId: 16790
|
||||
@ -9,44 +9,46 @@ dashedName: comparison-with-the-strict-equality-operator
|
||||
|
||||
# --description--
|
||||
|
||||
Strict equality (`===`) is the counterpart to the equality operator (`==`). However, unlike the equality operator, which attempts to convert both values being compared to a common type, the strict equality operator does not perform a type conversion.
|
||||
La estricta igualdad (`===`) es la contraparte del operador de igualdad (`==`). Sin embargo, a diferencia del operador de igualdad, el cual intenta convertir ambos valores comparados a un tipo común, el operador de estricta igualdad no realiza una conversión de tipo.
|
||||
|
||||
If the values being compared have different types, they are considered unequal, and the strict equality operator will return false.
|
||||
Si los valores que se comparan tienen diferentes tipos, se consideran desiguales, y el operador de estricta igualdad devolverá falso.
|
||||
|
||||
**Examples**
|
||||
**Ejemplos**
|
||||
|
||||
```js
|
||||
3 === 3 // true
|
||||
3 === '3' // false
|
||||
3 === 3
|
||||
3 === '3'
|
||||
```
|
||||
|
||||
In the second example, `3` is a `Number` type and `'3'` is a `String` type.
|
||||
Estas condiciones devuelven `true` y `false` respectivamente.
|
||||
|
||||
En el segundo ejemplo, `3` es de tipo `Number` (número) y `'3'` es de tipo `String` (cadena).
|
||||
|
||||
# --instructions--
|
||||
|
||||
Use the strict equality operator in the `if` statement so the function will return "Equal" when `val` is strictly equal to `7`
|
||||
Usa el operador de estricta igualdad en la sentencia `if` para que la función devuelva la cadena `Equal` cuando `val` sea estrictamente igual a `7`
|
||||
|
||||
# --hints--
|
||||
|
||||
`testStrict(10)` should return "Not Equal"
|
||||
`testStrict(10)` debe devolver la cadena `Not Equal`
|
||||
|
||||
```js
|
||||
assert(testStrict(10) === 'Not Equal');
|
||||
```
|
||||
|
||||
`testStrict(7)` should return "Equal"
|
||||
`testStrict(7)` debe devolver la cadena `Equal`
|
||||
|
||||
```js
|
||||
assert(testStrict(7) === 'Equal');
|
||||
```
|
||||
|
||||
`testStrict("7")` should return "Not Equal"
|
||||
`testStrict("7")` debe devolver la cadena `Not Equal`
|
||||
|
||||
```js
|
||||
assert(testStrict('7') === 'Not Equal');
|
||||
```
|
||||
|
||||
You should use the `===` operator
|
||||
Debes usar el operador `===`
|
||||
|
||||
```js
|
||||
assert(code.match(/(val\s*===\s*\d+)|(\d+\s*===\s*val)/g).length > 0);
|
||||
|
@ -9,7 +9,7 @@ dashedName: comparison-with-the-strict-inequality-operator
|
||||
|
||||
# --description--
|
||||
|
||||
El operador de estricta desigualdad `!==` es el opuesto lógico del operador de estricta igualdad. Esto significa "Estrictamente No Igual", y devuelve `false` cuando la comparación de estricta igualdad devolvería `true` y *vice versa*. Una estricta desigualdad no convertirá los tipos de datos.
|
||||
El operador de estricta desigualdad `!==` es el opuesto lógico del operador de estricta igualdad. Esto significa "Estrictamente Desigual", y devuelve `false` cuando la comparación de estricta igualdad devolvería `true` y *vice versa*. Una estricta desigualdad no convertirá los tipos de datos.
|
||||
|
||||
**Ejemplos**
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244d8
|
||||
title: Comparisons with the Logical And Operator
|
||||
title: Comparaciones con el operador lógico "and"
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/cvbRVtr'
|
||||
forumTopicId: 16799
|
||||
@ -9,9 +9,9 @@ dashedName: comparisons-with-the-logical-and-operator
|
||||
|
||||
# --description--
|
||||
|
||||
Sometimes you will need to test more than one thing at a time. The <dfn>logical and</dfn> operator (`&&`) returns `true` if and only if the <dfn>operands</dfn> to the left and right of it are true.
|
||||
A veces tendrás que probar más de una cosa a la vez. El operador <dfn>lógico and</dfn> (`&&`) devuelve `true` si y solo si los <dfn>operandos</dfn> a la izquierda y a la derecha son verdaderos.
|
||||
|
||||
The same effect could be achieved by nesting an if statement inside another if:
|
||||
El mismo efecto se podría lograr anidando una sentencia if dentro de otra sentencia if:
|
||||
|
||||
```js
|
||||
if (num > 5) {
|
||||
@ -22,7 +22,7 @@ if (num > 5) {
|
||||
return "No";
|
||||
```
|
||||
|
||||
will only return "Yes" if `num` is greater than `5` and less than `10`. The same logic can be written as:
|
||||
solo devolverá `Yes` si `num` es mayor que `5` y menor que `10`. La misma lógica se puede escribir como:
|
||||
|
||||
```js
|
||||
if (num > 5 && num < 10) {
|
||||
@ -33,65 +33,65 @@ return "No";
|
||||
|
||||
# --instructions--
|
||||
|
||||
Replace the two if statements with one statement, using the && operator, which will return `"Yes"` if `val` is less than or equal to `50` and greater than or equal to `25`. Otherwise, will return `"No"`.
|
||||
Reemplaza las dos sentencias if por una sola, usando el operador `&&`, el cual devolverá la cadena `Yes` si `val` es menor o igual a `50` y mayor o igual a `25`. De lo contrario, devolverá la cadena `No`.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should use the `&&` operator once
|
||||
Debes usar el operador `&&` una vez
|
||||
|
||||
```js
|
||||
assert(code.match(/&&/g).length === 1);
|
||||
```
|
||||
|
||||
You should only have one `if` statement
|
||||
Debes tener una sola sentencia `if`
|
||||
|
||||
```js
|
||||
assert(code.match(/if/g).length === 1);
|
||||
```
|
||||
|
||||
`testLogicalAnd(0)` should return "No"
|
||||
`testLogicalAnd(0)` debe devolver la cadena `No`
|
||||
|
||||
```js
|
||||
assert(testLogicalAnd(0) === 'No');
|
||||
```
|
||||
|
||||
`testLogicalAnd(24)` should return "No"
|
||||
`testLogicalAnd(24)` debe devolver la cadena `No`
|
||||
|
||||
```js
|
||||
assert(testLogicalAnd(24) === 'No');
|
||||
```
|
||||
|
||||
`testLogicalAnd(25)` should return "Yes"
|
||||
`testLogicalAnd(25)` debe devolver la cadena `Yes`
|
||||
|
||||
```js
|
||||
assert(testLogicalAnd(25) === 'Yes');
|
||||
```
|
||||
|
||||
`testLogicalAnd(30)` should return "Yes"
|
||||
`testLogicalAnd(30)` debe devolver la cadena `Yes`
|
||||
|
||||
```js
|
||||
assert(testLogicalAnd(30) === 'Yes');
|
||||
```
|
||||
|
||||
`testLogicalAnd(50)` should return "Yes"
|
||||
`testLogicalAnd(50)` debe devolver la cadena `Yes`
|
||||
|
||||
```js
|
||||
assert(testLogicalAnd(50) === 'Yes');
|
||||
```
|
||||
|
||||
`testLogicalAnd(51)` should return "No"
|
||||
`testLogicalAnd(51)` debe devolver la cadena `No`
|
||||
|
||||
```js
|
||||
assert(testLogicalAnd(51) === 'No');
|
||||
```
|
||||
|
||||
`testLogicalAnd(75)` should return "No"
|
||||
`testLogicalAnd(75)` debe devolver la cadena `No`
|
||||
|
||||
```js
|
||||
assert(testLogicalAnd(75) === 'No');
|
||||
```
|
||||
|
||||
`testLogicalAnd(80)` should return "No"
|
||||
`testLogicalAnd(80)` debe devolver la cadena `No`
|
||||
|
||||
```js
|
||||
assert(testLogicalAnd(80) === 'No');
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244d9
|
||||
title: Comparisons with the Logical Or Operator
|
||||
title: Comparaciones con el operador lógico "or"
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/cEPrGTN'
|
||||
forumTopicId: 16800
|
||||
@ -9,11 +9,11 @@ dashedName: comparisons-with-the-logical-or-operator
|
||||
|
||||
# --description--
|
||||
|
||||
The <dfn>logical or</dfn> operator (`||`) returns `true` if either of the <dfn>operands</dfn> is `true`. Otherwise, it returns `false`.
|
||||
El operador <dfn>lógico or</dfn> (`||`) devuelve `true` si cualquiera de los <dfn>operandos</dfn> es `true`. De lo contrario, devuelve `false`.
|
||||
|
||||
The <dfn>logical or</dfn> operator is composed of two pipe symbols: (`||`). This can typically be found between your Backspace and Enter keys.
|
||||
El operador <dfn>lógico or</dfn> se compone de dos símbolos de barra vertical: (`||`). Este se puede encontrar normalmente entre las teclas de tabulación y escape.
|
||||
|
||||
The pattern below should look familiar from prior waypoints:
|
||||
El patrón de abajo debería parecer familiar desde los puntos de referencia anteriores:
|
||||
|
||||
```js
|
||||
if (num > 10) {
|
||||
@ -25,7 +25,7 @@ if (num < 5) {
|
||||
return "Yes";
|
||||
```
|
||||
|
||||
will return "Yes" only if `num` is between `5` and `10` (5 and 10 included). The same logic can be written as:
|
||||
devolverá `Yes` sólo si `num` está entre `5` y `10` (5 y 10 incluidos). La misma lógica se puede escribir como:
|
||||
|
||||
```js
|
||||
if (num > 10 || num < 5) {
|
||||
@ -36,65 +36,65 @@ return "Yes";
|
||||
|
||||
# --instructions--
|
||||
|
||||
Combine the two `if` statements into one statement which returns `"Outside"` if `val` is not between `10` and `20`, inclusive. Otherwise, return `"Inside"`.
|
||||
Combina las dos sentencias `if` en una sola sentencia que devuelva la cadena `Outside` si `val` no está entre `10` y `20`, inclusivo. De lo contrario, devuelve la cadena `Inside`.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should use the `||` operator once
|
||||
Debes usar el operador `||` una vez
|
||||
|
||||
```js
|
||||
assert(code.match(/\|\|/g).length === 1);
|
||||
```
|
||||
|
||||
You should only have one `if` statement
|
||||
Debes tener una sola sentencia `if`
|
||||
|
||||
```js
|
||||
assert(code.match(/if/g).length === 1);
|
||||
```
|
||||
|
||||
`testLogicalOr(0)` should return "Outside"
|
||||
`testLogicalOr(0)` debe devolver la cadena `Outside`
|
||||
|
||||
```js
|
||||
assert(testLogicalOr(0) === 'Outside');
|
||||
```
|
||||
|
||||
`testLogicalOr(9)` should return "Outside"
|
||||
`testLogicalOr(9)` debe devolver la cadena `Outside`
|
||||
|
||||
```js
|
||||
assert(testLogicalOr(9) === 'Outside');
|
||||
```
|
||||
|
||||
`testLogicalOr(10)` should return "Inside"
|
||||
`testLogicalOr(10)` debe devolver la cadena `Inside`
|
||||
|
||||
```js
|
||||
assert(testLogicalOr(10) === 'Inside');
|
||||
```
|
||||
|
||||
`testLogicalOr(15)` should return "Inside"
|
||||
`testLogicalOr(15)` debe devolver la cadena `Inside`
|
||||
|
||||
```js
|
||||
assert(testLogicalOr(15) === 'Inside');
|
||||
```
|
||||
|
||||
`testLogicalOr(19)` should return "Inside"
|
||||
`testLogicalOr(19)` debe devolver la cadena `Inside`
|
||||
|
||||
```js
|
||||
assert(testLogicalOr(19) === 'Inside');
|
||||
```
|
||||
|
||||
`testLogicalOr(20)` should return "Inside"
|
||||
`testLogicalOr(20)` debe devolver la cadena `Inside`
|
||||
|
||||
```js
|
||||
assert(testLogicalOr(20) === 'Inside');
|
||||
```
|
||||
|
||||
`testLogicalOr(21)` should return "Outside"
|
||||
`testLogicalOr(21)` debe devolver la cadena `Outside`
|
||||
|
||||
```js
|
||||
assert(testLogicalOr(21) === 'Outside');
|
||||
```
|
||||
|
||||
`testLogicalOr(25)` should return "Outside"
|
||||
`testLogicalOr(25)` debe devolver la cadena `Outside`
|
||||
|
||||
```js
|
||||
assert(testLogicalOr(25) === 'Outside');
|
||||
|
@ -20,9 +20,11 @@ Uno de estos operadores es el operador `+=`.
|
||||
```js
|
||||
var myVar = 1;
|
||||
myVar += 5;
|
||||
console.log(myVar); // Returns 6
|
||||
console.log(myVar);
|
||||
```
|
||||
|
||||
Se mostrará un `6` en la consola.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Convierte las asignaciones de `a`, `b` y `c` para que utilicen el operador `+=`.
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244b2
|
||||
title: Compound Assignment With Augmented Division
|
||||
title: Asignación compuesta con división aumentada
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/c2QvKT2'
|
||||
forumTopicId: 16659
|
||||
@ -9,45 +9,45 @@ dashedName: compound-assignment-with-augmented-division
|
||||
|
||||
# --description--
|
||||
|
||||
The `/=` operator divides a variable by another number.
|
||||
El operador `/=` divide una variable entre otro número.
|
||||
|
||||
`myVar = myVar / 5;`
|
||||
|
||||
Will divide `myVar` by `5`. This can be rewritten as:
|
||||
Dividirá `myVar` entre `5`. Esto se puede reescribir como:
|
||||
|
||||
`myVar /= 5;`
|
||||
|
||||
# --instructions--
|
||||
|
||||
Convert the assignments for `a`, `b`, and `c` to use the `/=` operator.
|
||||
Convierte las asignaciones de `a`, `b` y `c` para que utilicen el operador `/=`.
|
||||
|
||||
# --hints--
|
||||
|
||||
`a` should equal `4`.
|
||||
`a` debe ser igual a `4`.
|
||||
|
||||
```js
|
||||
assert(a === 4);
|
||||
```
|
||||
|
||||
`b` should equal `27`.
|
||||
`b` debe ser igual a `27`.
|
||||
|
||||
```js
|
||||
assert(b === 27);
|
||||
```
|
||||
|
||||
`c` should equal `3`.
|
||||
`c` debe ser igual a `3`.
|
||||
|
||||
```js
|
||||
assert(c === 3);
|
||||
```
|
||||
|
||||
You should use the `/=` operator for each variable.
|
||||
Debes usar el operador `/=` para cada variable.
|
||||
|
||||
```js
|
||||
assert(code.match(/\/=/g).length === 3);
|
||||
```
|
||||
|
||||
You should not modify the code above the specified comment.
|
||||
No debes modificar el código por encima del comentario especificado.
|
||||
|
||||
```js
|
||||
assert(
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244b7
|
||||
title: Concatenating Strings with Plus Operator
|
||||
title: Concatena cadenas con el operador "más"
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/cNpM8AN'
|
||||
forumTopicId: 16802
|
||||
@ -9,49 +9,48 @@ dashedName: concatenating-strings-with-plus-operator
|
||||
|
||||
# --description--
|
||||
|
||||
In JavaScript, when the `+` operator is used with a `String` value, it is called the <dfn>concatenation</dfn> operator. You can build a new string out of other strings by <dfn>concatenating</dfn> them together.
|
||||
En JavaScript, cuando el operador `+` se utiliza con un valor de cadena (`String`), se le llama operador de <dfn>concatenación</dfn>. Puedes construir una nueva cadena a partir de otras cadenas <dfn>concatenándolas</dfn> juntas.
|
||||
|
||||
**Example**
|
||||
**Ejemplo**
|
||||
|
||||
```js
|
||||
'My name is Alan,' + ' I concatenate.'
|
||||
```
|
||||
|
||||
**Note**
|
||||
Watch out for spaces. Concatenation does not add spaces between concatenated strings, so you'll need to add them yourself.
|
||||
**Nota:** Ten cuidado con los espacios. La concatenación no añade espacios entre las cadenas concatenadas, así que tendrás que añadirlos por tu cuenta.
|
||||
|
||||
Example:
|
||||
Ejemplo:
|
||||
|
||||
```js
|
||||
var ourStr = "I come first. " + "I come second.";
|
||||
// ourStr is "I come first. I come second."
|
||||
```
|
||||
|
||||
La cadena `I come first. I come second.` se mostrará en la consola.
|
||||
# --instructions--
|
||||
|
||||
Build `myStr` from the strings `"This is the start. "` and `"This is the end."` using the `+` operator.
|
||||
Construye `myStr` a partir de las cadenas `This is the start.` y `This is the end.` utilizando el operador `+`.
|
||||
|
||||
# --hints--
|
||||
|
||||
`myStr` should have a value of `This is the start. This is the end.`
|
||||
`myStr` debe tener una cadena con valor `This is the start. This is the end.`
|
||||
|
||||
```js
|
||||
assert(myStr === 'This is the start. This is the end.');
|
||||
```
|
||||
|
||||
You should use the `+` operator to build `myStr`.
|
||||
Debes usar el operador `+` para construir `myStr`.
|
||||
|
||||
```js
|
||||
assert(code.match(/(["']).*\1\s*\+\s*(["']).*\2/g));
|
||||
```
|
||||
|
||||
`myStr` should be created using the `var` keyword.
|
||||
`myStr` debe ser creada usando la palabra clave `var`.
|
||||
|
||||
```js
|
||||
assert(/var\s+myStr/.test(code));
|
||||
```
|
||||
|
||||
You should assign the result to the `myStr` variable.
|
||||
Debes asignar el resultado a la variable `myStr`.
|
||||
|
||||
```js
|
||||
assert(/myStr\s*=/.test(code));
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244b9
|
||||
title: Constructing Strings with Variables
|
||||
title: Construye cadenas con variables
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/cqk8rf4'
|
||||
forumTopicId: 16805
|
||||
@ -9,29 +9,30 @@ dashedName: constructing-strings-with-variables
|
||||
|
||||
# --description--
|
||||
|
||||
Sometimes you will need to build a string, [Mad Libs](https://en.wikipedia.org/wiki/Mad_Libs) style. By using the concatenation operator (`+`), you can insert one or more variables into a string you're building.
|
||||
A veces necesitarás construir una cadena, al estilo [Mad Libs](https://en.wikipedia.org/wiki/Mad_Libs). Al usar el operador de concatenación (`+`), puedes insertar una o más variables en una cadena que estés construyendo.
|
||||
|
||||
Example:
|
||||
Ejemplo:
|
||||
|
||||
```js
|
||||
var ourName = "freeCodeCamp";
|
||||
var ourStr = "Hello, our name is " + ourName + ", how are you?";
|
||||
// ourStr is now "Hello, our name is freeCodeCamp, how are you?"
|
||||
```
|
||||
|
||||
`ourStr` tendrá como valor la cadena `Hello, our name is freeCodeCamp, how are you?`.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Set `myName` to a string equal to your name and build `myStr` with `myName` between the strings `"My name is "` and `" and I am well!"`
|
||||
Establece `myName` en una cadena igual a tu nombre y construye `myStr` con `myName` entre las cadenas `My name is` y `and I am well!`
|
||||
|
||||
# --hints--
|
||||
|
||||
`myName` should be set to a string at least 3 characters long.
|
||||
`myName` debe establecerse en una cadena de al menos 3 caracteres de largo.
|
||||
|
||||
```js
|
||||
assert(typeof myName !== 'undefined' && myName.length > 2);
|
||||
```
|
||||
|
||||
You should use two `+` operators to build `myStr` with `myName` inside it.
|
||||
Debes usar dos operadores `+` para construir `myStr` con `myName` dentro de él.
|
||||
|
||||
```js
|
||||
assert(code.match(/["']\s*\+\s*myName\s*\+\s*["']/g).length > 0);
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 56105e7b514f539506016a5e
|
||||
title: Count Backwards With a For Loop
|
||||
title: Cuenta hacia atrás con un bucle "for"
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/c2R6BHa'
|
||||
forumTopicId: 16808
|
||||
@ -9,11 +9,11 @@ dashedName: count-backwards-with-a-for-loop
|
||||
|
||||
# --description--
|
||||
|
||||
A for loop can also count backwards, so long as we can define the right conditions.
|
||||
Un bucle for también puede contar hacia atrás, siempre que definamos las condiciones adecuadas.
|
||||
|
||||
In order to decrement by two each iteration, we'll need to change our `initialization`, `condition`, and `final-expression`.
|
||||
Para poder disminuirle dos cada iteración, necesitaremos cambiar nuestra inicialización, condición, y expresión final.
|
||||
|
||||
We'll start at `i = 10` and loop while `i > 0`. We'll decrement `i` by 2 each loop with `i -= 2`.
|
||||
Empezaremos en `i = 10` e iteraremos mientras `i > 0`. Disminuiremos `i` en 2 por cada bucle con `i -= 2`.
|
||||
|
||||
```js
|
||||
var ourArray = [];
|
||||
@ -22,27 +22,27 @@ for (var i = 10; i > 0; i -= 2) {
|
||||
}
|
||||
```
|
||||
|
||||
`ourArray` will now contain `[10,8,6,4,2]`. Let's change our `initialization` and `final-expression` so we can count backward by twos by odd numbers.
|
||||
`ourArray` ahora contendrá `[10,8,6,4,2]`. Cambiemos nuestra inicialización y expresión final para que podamos contar hacia atrás por dos números impares.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Push the odd numbers from 9 through 1 to `myArray` using a `for` loop.
|
||||
Inserta los números impares desde el 9 hasta el 1 en `myArray` utilizando un bucle `for`.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should be using a `for` loop for this.
|
||||
Debes utilizar un bucle `for` para esto.
|
||||
|
||||
```js
|
||||
assert(/for\s*\([^)]+?\)/.test(code));
|
||||
```
|
||||
|
||||
You should be using the array method `push`.
|
||||
Debes utilizar el método de arreglo `push`.
|
||||
|
||||
```js
|
||||
assert(code.match(/myArray.push/));
|
||||
```
|
||||
|
||||
`myArray` should equal `[9,7,5,3,1]`.
|
||||
`myArray` debe ser igual a `[9,7,5,3,1]`.
|
||||
|
||||
```js
|
||||
assert.deepEqual(myArray, [9, 7, 5, 3, 1]);
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 565bbe00e9cc8ac0725390f4
|
||||
title: Counting Cards
|
||||
title: Conteo de cartas
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/c6KE7ty'
|
||||
forumTopicId: 16809
|
||||
@ -9,25 +9,25 @@ dashedName: counting-cards
|
||||
|
||||
# --description--
|
||||
|
||||
In the casino game Blackjack, a player can gain an advantage over the house by keeping track of the relative number of high and low cards remaining in the deck. This is called [Card Counting](https://en.wikipedia.org/wiki/Card_counting).
|
||||
En el juego de casino Blackjack el jugador puede sacarle ventaja a la casa llevando un registro del numero relativo de cartas altas y bajas que quedan en la baraja. Esto es llamado [conteo de cartas](https://es.wikipedia.org/wiki/Conteo_de_cartas).
|
||||
|
||||
Having more high cards remaining in the deck favors the player. Each card is assigned a value according to the table below. When the count is positive, the player should bet high. When the count is zero or negative, the player should bet low.
|
||||
Tener más cartas altas en la baraja es una ventaja para el jugador. Se le asigna una valor a cada carta de acuerdo a la siguiente tabla. Cuando el conteo es positivo, el jugador debería apostar alto. Cuando el conteo da 0 o negativo, el jugador debería apostar bajo.
|
||||
|
||||
<table class='table table-striped'><thead><tr><th>Count Change</th><th>Cards</th></tr></thead><tbody><tr><td>+1</td><td>2, 3, 4, 5, 6</td></tr><tr><td>0</td><td>7, 8, 9</td></tr><tr><td>-1</td><td>10, 'J', 'Q', 'K', 'A'</td></tr></tbody></table>
|
||||
<table class='table table-striped'><thead><tr><th>Cambios del conteo</th><th>Cartas</th></tr></thead><tbody><tr><td>+1</td><td>2, 3, 4, 5, 6</td></tr><tr><td>0</td><td>7, 8, 9</td></tr><tr><td>-1</td><td>10, 'J', 'Q', 'K', 'A'</td></tr></tbody></table>
|
||||
|
||||
You will write a card counting function. It will receive a `card` parameter, which can be a number or a string, and increment or decrement the global `count` variable according to the card's value (see table). The function will then return a string with the current count and the string `Bet` if the count is positive, or `Hold` if the count is zero or negative. The current count and the player's decision (`Bet` or `Hold`) should be separated by a single space.
|
||||
Escribirás una función para contar cartas. Recibirá un parámetro `card` (carta) que puede ser un número o una cadena y aumentar o reducir la variable global `count` (conteo) de acuerdo al valor de la carta (observa la tabla). La función devolverá una cadena con el conteo actual y la cadena `Bet` (Apuesta) si el conteo es positivo, o `Hold` (Espera) si el conteo es cero o negativo. El conteo actual y la decisión del jugador (`Bet` o `Hold`) deben estar separados por un solo espacio.
|
||||
|
||||
**Example Output**
|
||||
**Ejemplo de salida**
|
||||
`-3 Hold`
|
||||
`5 Bet`
|
||||
|
||||
**Hint**
|
||||
Do NOT reset `count` to 0 when value is 7, 8, or 9. Do NOT return an array.
|
||||
Do NOT include quotes (single or double) in the output.
|
||||
**Sugerencia**
|
||||
NO reinicies `count` a 0 cuando el valor sea 7, 8 o 9. NO devuelvas un arreglo.
|
||||
NO incluyas comillas (individuales o dobles) en el resultado.
|
||||
|
||||
# --hints--
|
||||
|
||||
Cards Sequence 2, 3, 4, 5, 6 should return `5 Bet`
|
||||
La secuencia de cartas 2, 3, 4, 5, 6 debe devolver `5 Bet`
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -46,7 +46,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
Cards Sequence 7, 8, 9 should return `0 Hold`
|
||||
La secuencia de cartas 7, 8, 9 debe devolver la cadena `0 Hold`
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -63,7 +63,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
Cards Sequence 10, J, Q, K, A should return `-5 Hold`
|
||||
La secuencia de cartas 10, J, Q, K, A debe devolver la cadena `-5 Hold`
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -82,7 +82,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
Cards Sequence 3, 7, Q, 8, A should return `-1 Hold`
|
||||
La secuencia de cartas 3, 7, Q, 8, A debe devolver la cadena `-1 Hold`
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -101,7 +101,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
Cards Sequence 2, J, 9, 2, 7 should return `1 Bet`
|
||||
La secuencia de cartas 2, J, 9, 2, 7 debe devolver la cadena `1 Bet`
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -120,7 +120,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
Cards Sequence 2, 2, 10 should return `1 Bet`
|
||||
La secuencia de cartas 2, 2, 10 debe devolver la cadena `1 Bet`
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -137,7 +137,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
Cards Sequence 3, 2, A, 10, K should return `-1 Hold`
|
||||
La secuencia de cartas 3, 2, A, 10, K debe devolver la cadena `-1 Hold`
|
||||
|
||||
```js
|
||||
assert(
|
||||
|
@ -11,8 +11,7 @@ dashedName: create-decimal-numbers-with-javascript
|
||||
|
||||
También podemos almacenar números decimales en variables. Los números decimales a veces se denominan números de <dfn>coma flotante</dfn> o <dfn>flotantes</dfn>.
|
||||
|
||||
**Nota**
|
||||
No todos los números reales pueden representarse con precisión en <dfn>coma flotante</dfn>. Esto puede llevar a errores de redondeo. [Detalles aquí](https://en.wikipedia.org/wiki/Floating_point#Accuracy_problems).
|
||||
**Nota:** No todos los números reales pueden representarse con precisión en <dfn>coma flotante</dfn>. Esto puede llevar a errores de redondeo. [Detalles aquí](https://en.wikipedia.org/wiki/Floating_point#Accuracy_problems).
|
||||
|
||||
# --instructions--
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: bd7123c9c444eddfaeb5bdef
|
||||
title: Declare String Variables
|
||||
title: Declara variables de cadena
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/c2QvWU6'
|
||||
forumTopicId: 17557
|
||||
@ -9,19 +9,19 @@ dashedName: declare-string-variables
|
||||
|
||||
# --description--
|
||||
|
||||
Previously we have used the code
|
||||
Anteriormente hemos usado el código
|
||||
|
||||
`var myName = "your name";`
|
||||
|
||||
`"your name"` is called a <dfn>string</dfn> <dfn>literal</dfn>. It is a string because it is a series of zero or more characters enclosed in single or double quotes.
|
||||
`"your name"` es llamada una <dfn>cadena</dfn> <dfn>literal</dfn>. Es una cadena porque es una serie de cero o más caracteres encerrados entre comillas simples o dobles.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Create two new `string` variables: `myFirstName` and `myLastName` and assign them the values of your first and last name, respectively.
|
||||
Crea dos nuevas variables de cadena: `myFirstName` y `myLastName` y asígnales los valores de tu nombre y apellido, respectivamente.
|
||||
|
||||
# --hints--
|
||||
|
||||
`myFirstName` should be a string with at least one character in it.
|
||||
`myFirstName` debe ser una cadena con al menos un carácter en ella.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -39,7 +39,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
`myLastName` should be a string with at least one character in it.
|
||||
`myLastName` debe ser una cadena con al menos un carácter en ella.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -66,7 +66,9 @@ if(typeof myFirstName !== "undefined" && typeof myLastName !== "undefined"){(fun
|
||||
```
|
||||
|
||||
## --seed-contents--
|
||||
|
||||
```js
|
||||
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
@ -17,8 +17,7 @@ es equivalente a
|
||||
|
||||
`i = i - 1;`
|
||||
|
||||
**Nota**
|
||||
Toda la línea se convierte en `i--;`, eliminando la necesidad del signo de igualdad.
|
||||
**Nota:** Toda la línea se convierte en `i--;`, eliminando la necesidad del signo de igualdad.
|
||||
|
||||
# --instructions--
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 56bbb991ad1ed5201cd392d3
|
||||
title: Delete Properties from a JavaScript Object
|
||||
title: Elimina propiedades en un objeto de JavaScript
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/cDqKdTv'
|
||||
forumTopicId: 17560
|
||||
@ -9,11 +9,11 @@ dashedName: delete-properties-from-a-javascript-object
|
||||
|
||||
# --description--
|
||||
|
||||
We can also delete properties from objects like this:
|
||||
También podemos eliminar propiedades de objetos de esta forma:
|
||||
|
||||
`delete ourDog.bark;`
|
||||
|
||||
Example:
|
||||
Ejemplo:
|
||||
|
||||
```js
|
||||
var ourDog = {
|
||||
@ -27,7 +27,7 @@ var ourDog = {
|
||||
delete ourDog.bark;
|
||||
```
|
||||
|
||||
After the last line shown above, `ourDog` looks like:
|
||||
Después de la última línea mostrada anteriormente, `ourDog` se ve así:
|
||||
|
||||
```js
|
||||
{
|
||||
@ -40,17 +40,17 @@ After the last line shown above, `ourDog` looks like:
|
||||
|
||||
# --instructions--
|
||||
|
||||
Delete the `"tails"` property from `myDog`. You may use either dot or bracket notation.
|
||||
Elimina la propiedad `tails` de `myDog`. Puedes usar tanto la notación de puntos como la notación de corchetes.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should delete the property `"tails"` from `myDog`.
|
||||
Debes eliminar la propiedad `tails` de `myDog`.
|
||||
|
||||
```js
|
||||
assert(typeof myDog === 'object' && myDog.tails === undefined);
|
||||
```
|
||||
|
||||
You should not modify the `myDog` setup.
|
||||
No debes modificar la disposición de `myDog`.
|
||||
|
||||
```js
|
||||
assert(code.match(/"tails": 1/g).length > 0);
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: bd7993c9ca9feddfaeb7bdef
|
||||
title: Divide One Decimal by Another with JavaScript
|
||||
title: Divide un decimal entre otro con JavaScript
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/cBZe9AW'
|
||||
forumTopicId: 18255
|
||||
@ -9,27 +9,27 @@ dashedName: divide-one-decimal-by-another-with-javascript
|
||||
|
||||
# --description--
|
||||
|
||||
Now let's divide one decimal by another.
|
||||
Ahora dividamos un decimal entre otro.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Change the `0.0` so that `quotient` will equal to `2.2`.
|
||||
Cambia el `0.0` para que el cociente (`quotient`) sea igual a `2.2`.
|
||||
|
||||
# --hints--
|
||||
|
||||
The variable `quotient` should equal `2.2`
|
||||
La variable `quotient` debe ser igual a `2.2`
|
||||
|
||||
```js
|
||||
assert(quotient === 2.2);
|
||||
```
|
||||
|
||||
You should use the `/` operator to divide 4.4 by 2
|
||||
Debes usar el operador `/` para dividir 4.4 entre 2
|
||||
|
||||
```js
|
||||
assert(/4\.40*\s*\/\s*2\.*0*/.test(code));
|
||||
```
|
||||
|
||||
The quotient variable should only be assigned once
|
||||
La variable quotient debe ser asignada solo una vez
|
||||
|
||||
```js
|
||||
assert(code.match(/quotient/g).length === 1);
|
||||
|
@ -16,9 +16,10 @@ JavaScript utiliza el símbolo `/` para la división.
|
||||
**Ejemplo**
|
||||
|
||||
```js
|
||||
myVar = 16 / 2; // assigned 8
|
||||
myVar = 16 / 2;
|
||||
```
|
||||
|
||||
`myVar` ahora tiene el valor `8`.
|
||||
# --instructions--
|
||||
|
||||
Cambia el `0` para que el `quotient` (cociente) sea igual a `2`.
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: bd7123c9c448eddfaeb5bdef
|
||||
title: Find the Length of a String
|
||||
title: Encuentra la longitud de una cadena
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/cvmqEAd'
|
||||
forumTopicId: 18182
|
||||
@ -9,19 +9,23 @@ dashedName: find-the-length-of-a-string
|
||||
|
||||
# --description--
|
||||
|
||||
You can find the length of a `String` value by writing `.length` after the string variable or string literal.
|
||||
Puedes encontrar la longitud de un valor de cadena (`String`) escribiendo `.length` después de la variable de cadena o literal de cadena.
|
||||
|
||||
`"Alan Peter".length; // 10`
|
||||
```js
|
||||
console.log("Alan Peter".length);
|
||||
```
|
||||
|
||||
For example, if we created a variable `var firstName = "Charles"`, we could find out how long the string `"Charles"` is by using the `firstName.length` property.
|
||||
El valor `10` se mostrará en la consola.
|
||||
|
||||
Por ejemplo, si creamos una variable `var firstName = "Charles"`, podríamos averiguar la longitud de la cadena `Charles` usando la propiedad `firstName.length`.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Use the `.length` property to count the number of characters in the `lastName` variable and assign it to `lastNameLength`.
|
||||
Usa la propiedad `.length` para contar el número de caracteres en la variable `lastName` y asignarla a `lastNameLength`.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should not change the variable declarations in the `// Setup` section.
|
||||
No debes cambiar las declaraciones de variables en la sección `// Setup`.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -30,13 +34,13 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
`lastNameLength` should be equal to eight.
|
||||
`lastNameLength` debe ser igual a ocho.
|
||||
|
||||
```js
|
||||
assert(typeof lastNameLength !== 'undefined' && lastNameLength === 8);
|
||||
```
|
||||
|
||||
You should be getting the length of `lastName` by using `.length` like this: `lastName.length`.
|
||||
Debes obtener la longitud de `lastName` usando `.length` de esta forma: `lastName.length`.
|
||||
|
||||
```js
|
||||
assert(code.match(/=\s*lastName\.length/g) && !code.match(/lastName\s*=\s*8/));
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244ae
|
||||
title: Finding a Remainder in JavaScript
|
||||
title: Encuentra un resto en JavaScript
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/cWP24Ub'
|
||||
forumTopicId: 18184
|
||||
@ -9,39 +9,38 @@ dashedName: finding-a-remainder-in-javascript
|
||||
|
||||
# --description--
|
||||
|
||||
The <dfn>remainder</dfn> operator `%` gives the remainder of the division of two numbers.
|
||||
El operador de <dfn>resto</dfn> `%` entrega el resto de la división entre dos números.
|
||||
|
||||
**Example**
|
||||
**Ejemplo**
|
||||
|
||||
<blockquote>5 % 2 = 1 because<br>Math.floor(5 / 2) = 2 (Quotient)<br>2 * 2 = 4<br>5 - 4 = 1 (Remainder)</blockquote>
|
||||
<blockquote>5 % 2 = 1 porque<br>Math.floor(5 / 2) = 2 (Cociente)<br>2 * 2 = 4<br>5 - 4 = 1 (Resto)</blockquote>
|
||||
|
||||
**Usage**
|
||||
In mathematics, a number can be checked to be even or odd by checking the remainder of the division of the number by `2`.
|
||||
**Uso**
|
||||
En matemáticas, un número se puede comprobar para saber si es par o impar revisando el resto de la división del número por `2`.
|
||||
|
||||
<blockquote>17 % 2 = 1 (17 is Odd)<br>48 % 2 = 0 (48 is Even)</blockquote>
|
||||
<blockquote>17 % 2 = 1 (17 es impar)<br>48 % 2 = 0 (48 es par)</blockquote>
|
||||
|
||||
**Note**
|
||||
The <dfn>remainder</dfn> operator is sometimes incorrectly referred to as the "modulus" operator. It is very similar to modulus, but does not work properly with negative numbers.
|
||||
**Nota:** El operador de <dfn>resto</dfn> es a veces incorrectamente referido como el operador módulo. Es muy similar al módulo, pero no funciona adecuadamente con números negativos.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Set `remainder` equal to the remainder of `11` divided by `3` using the <dfn>remainder</dfn> (`%`) operator.
|
||||
Establece `remainder` igual al resto de `11` dividido entre `3` usando el operador de <dfn>resto</dfn> (`%`).
|
||||
|
||||
# --hints--
|
||||
|
||||
The variable `remainder` should be initialized
|
||||
La variable `remainder` debe inicializarse
|
||||
|
||||
```js
|
||||
assert(/var\s+?remainder/.test(code));
|
||||
```
|
||||
|
||||
The value of `remainder` should be `2`
|
||||
El valor de `remainder` debe ser `2`
|
||||
|
||||
```js
|
||||
assert(remainder === 2);
|
||||
```
|
||||
|
||||
You should use the `%` operator
|
||||
Debes usar el operador `%`
|
||||
|
||||
```js
|
||||
assert(/\s+?remainder\s*?=\s*?.*%.*;?/.test(code));
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: cf1111c1c11feddfaeb9bdef
|
||||
title: Generate Random Fractions with JavaScript
|
||||
title: Genera fracciones aleatorias con JavaScript
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/cyWJJs3'
|
||||
forumTopicId: 18185
|
||||
@ -9,32 +9,31 @@ dashedName: generate-random-fractions-with-javascript
|
||||
|
||||
# --description--
|
||||
|
||||
Random numbers are useful for creating random behavior.
|
||||
Los números aleatorios son útiles para crear comportamientos aleatorios.
|
||||
|
||||
JavaScript has a `Math.random()` function that generates a random decimal number between `0` (inclusive) and not quite up to `1` (exclusive). Thus `Math.random()` can return a `0` but never quite return a `1`
|
||||
JavaScript tiene una función `Math.random()` que genera un número decimal aleatorio entre `0` (inclusivo) y `1` (exclusivo). Así que `Math.random()` puede devolver un `0` pero nunca devuelve un `1`
|
||||
|
||||
**Note**
|
||||
Like [Storing Values with the Equal Operator](/learn/javascript-algorithms-and-data-structures/basic-javascript/storing-values-with-the-assignment-operator), all function calls will be resolved before the `return` executes, so we can `return` the value of the `Math.random()` function.
|
||||
**Nota:** Así como aprendimos en [almacenando valores con el operador de igualdad](/learn/javascript-algorithms-and-data-structures/basic-javascript/storing-values-with-the-assignment-operator), todas las llamadas de funciones se resolverán antes de que el `return` se ejecute, así que podemos devolver (`return`) el valor de la función `Math.random()`.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Change `randomFraction` to return a random number instead of returning `0`.
|
||||
Cambia `randomFraction` para que devuelva un número aleatorio en lugar de devolver `0`.
|
||||
|
||||
# --hints--
|
||||
|
||||
`randomFraction` should return a random number.
|
||||
`randomFraction` debe devolver un número aleatorio.
|
||||
|
||||
```js
|
||||
assert(typeof randomFraction() === 'number');
|
||||
```
|
||||
|
||||
The number returned by `randomFraction` should be a decimal.
|
||||
El número devuelto por `randomFraction` debe ser un decimal.
|
||||
|
||||
```js
|
||||
assert((randomFraction() + '').match(/\./g));
|
||||
```
|
||||
|
||||
You should be using `Math.random` to generate the random decimal number.
|
||||
Debes usar `Math.random` para generar el número decimal aleatorio.
|
||||
|
||||
```js
|
||||
assert(code.match(/Math\.random/g).length >= 0);
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244be
|
||||
title: Global Scope and Functions
|
||||
title: Ámbito global y funciones
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/cQM7mCN'
|
||||
forumTopicId: 18193
|
||||
@ -9,37 +9,37 @@ dashedName: global-scope-and-functions
|
||||
|
||||
# --description--
|
||||
|
||||
In JavaScript, <dfn>scope</dfn> refers to the visibility of variables. Variables which are defined outside of a function block have <dfn>Global</dfn> scope. This means, they can be seen everywhere in your JavaScript code.
|
||||
En JavaScript, el <dfn>ámbito</dfn> se refiere a la visibilidad de las variables. Las variables definidas fuera de un bloque de función tienen un ámbito <dfn>Global</dfn>. Esto significa que pueden ser observadas desde cualquier lugar en tu código JavaScript.
|
||||
|
||||
Variables which are used without the `var` keyword are automatically created in the `global` scope. This can create unintended consequences elsewhere in your code or when running a function again. You should always declare your variables with `var`.
|
||||
Las variables que se usan sin la palabra clave `var` se crean automáticamente en el ámbito `global`. Esto puede crear consecuencias no intencionadas en cualquier lugar de tu código o al volver a ejecutar una función. Siempre debes declarar tus variables con `var`.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Using `var`, declare a global variable named `myGlobal` outside of any function. Initialize it with a value of `10`.
|
||||
Usando `var`, declara una variable global llamada `myGlobal` fuera de cualquier función. Inicialízala con un valor de `10`.
|
||||
|
||||
Inside function `fun1`, assign `5` to `oopsGlobal` ***without*** using the `var` keyword.
|
||||
Dentro de la función `fun1`, asigna `5` a `oopsGlobal` ***sin*** usar la palabra clave `var`.
|
||||
|
||||
# --hints--
|
||||
|
||||
`myGlobal` should be defined
|
||||
`myGlobal` debe ser definida
|
||||
|
||||
```js
|
||||
assert(typeof myGlobal != 'undefined');
|
||||
```
|
||||
|
||||
`myGlobal` should have a value of `10`
|
||||
`myGlobal` debe tener un valor de `10`
|
||||
|
||||
```js
|
||||
assert(myGlobal === 10);
|
||||
```
|
||||
|
||||
`myGlobal` should be declared using the `var` keyword
|
||||
`myGlobal` debe declararse usando la palabra clave `var`
|
||||
|
||||
```js
|
||||
assert(/var\s+myGlobal/.test(code));
|
||||
```
|
||||
|
||||
`oopsGlobal` should be a global variable and have a value of `5`
|
||||
`oopsGlobal` debe ser una variable global y tener un valor de `5`
|
||||
|
||||
```js
|
||||
assert(typeof oopsGlobal != 'undefined' && oopsGlobal === 5);
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244c0
|
||||
title: Global vs. Local Scope in Functions
|
||||
title: Ámbito global vs. local en funciones
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/c2QwKH2'
|
||||
forumTopicId: 18194
|
||||
@ -9,9 +9,9 @@ dashedName: global-vs--local-scope-in-functions
|
||||
|
||||
# --description--
|
||||
|
||||
It is possible to have both <dfn>local</dfn> and <dfn>global</dfn> variables with the same name. When you do this, the `local` variable takes precedence over the `global` variable.
|
||||
Es posible tener variables <dfn>locales</dfn> y <dfn>globales</dfn> con el mismo nombre. Cuando haces esto, la variable `local` tiene precedencia sobre la variable `global`.
|
||||
|
||||
In this example:
|
||||
En este ejemplo:
|
||||
|
||||
```js
|
||||
var someVar = "Hat";
|
||||
@ -21,27 +21,27 @@ function myFun() {
|
||||
}
|
||||
```
|
||||
|
||||
The function `myFun` will return `"Head"` because the `local` version of the variable is present.
|
||||
La función `myFun` devolverá la cadena `Head` porque está presente la versión `local` de la variable.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Add a local variable to `myOutfit` function to override the value of `outerWear` with `"sweater"`.
|
||||
Añade una variable local a la función `myOutfit` para sobrescribir el valor de `outerWear` con la cadena `sweater`.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should not change the value of the global `outerWear`.
|
||||
No debes cambiar el valor del `outerWear` global.
|
||||
|
||||
```js
|
||||
assert(outerWear === 'T-Shirt');
|
||||
```
|
||||
|
||||
`myOutfit` should return `"sweater"`.
|
||||
`myOutfit` debe devolver la cadena `sweater`.
|
||||
|
||||
```js
|
||||
assert(myOutfit() === 'sweater');
|
||||
```
|
||||
|
||||
You should not change the return statement.
|
||||
No debes cambiar la declaración de devolución.
|
||||
|
||||
```js
|
||||
assert(/return outerWear/.test(code));
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 5664820f61c48e80c9fa476c
|
||||
title: Golf Code
|
||||
title: Código de golf
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/c9ykNUR'
|
||||
forumTopicId: 18195
|
||||
@ -9,77 +9,77 @@ dashedName: golf-code
|
||||
|
||||
# --description--
|
||||
|
||||
In the game of [golf](https://en.wikipedia.org/wiki/Golf) each hole has a `par` meaning the average number of `strokes` a golfer is expected to make in order to sink the ball in a hole to complete the play. Depending on how far above or below `par` your `strokes` are, there is a different nickname.
|
||||
En el juego de [golf](https://en.wikipedia.org/wiki/Golf) cada hoyo tiene un `par` que significa el número promedio de `strokes` (golpes) que se espera que haga un golfista para introducir la pelota en un hoyo para completar la jugada. Dependiendo de qué tan por encima o por debajo del `par` estén tus `strokes`, hay un nombre diferente.
|
||||
|
||||
Your function will be passed `par` and `strokes` arguments. Return the correct string according to this table which lists the strokes in order of priority; top (highest) to bottom (lowest):
|
||||
Tu función recibirá los argumentos `par` y `strokes`. Devuelve la cadena correcta según esta tabla que muestra los golpes en orden de prioridad; superior (más alto) a inferior (más bajo):
|
||||
|
||||
<table class='table table-striped'><thead><tr><th>Strokes</th><th>Return</th></tr></thead><tbody><tr><td>1</td><td>"Hole-in-one!"</td></tr><tr><td><= par - 2</td><td>"Eagle"</td></tr><tr><td>par - 1</td><td>"Birdie"</td></tr><tr><td>par</td><td>"Par"</td></tr><tr><td>par + 1</td><td>"Bogey"</td></tr><tr><td>par + 2</td><td>"Double Bogey"</td></tr><tr><td>>= par + 3</td><td>"Go Home!"</td></tr></tbody></table>
|
||||
<table class='table table-striped'><thead><tr><th>Strokes (golpes)</th><th>Devuelve</th></tr></thead><tbody><tr><td>1</td><td>"Hole-in-one!"</td></tr><tr><td><= par - 2</td><td>"Eagle"</td></tr><tr><td>par - 1</td><td>"Birdie"</td></tr><tr><td>par</td><td>"Par"</td></tr><tr><td>par + 1</td><td>"Bogey"</td></tr><tr><td>par + 2</td><td>"Double Bogey"</td></tr><tr><td>>= par + 3</td><td>"Go Home!"</td></tr></tbody></table>
|
||||
|
||||
`par` and `strokes` will always be numeric and positive. We have added an array of all the names for your convenience.
|
||||
`par` y `strokes` siempre serán numéricos y positivos. Hemos añadido un arreglo de todos los nombres para tu conveniencia.
|
||||
|
||||
# --hints--
|
||||
|
||||
`golfScore(4, 1)` should return "Hole-in-one!"
|
||||
`golfScore(4, 1)` debe devolver la cadena `Hole-in-one!`
|
||||
|
||||
```js
|
||||
assert(golfScore(4, 1) === 'Hole-in-one!');
|
||||
```
|
||||
|
||||
`golfScore(4, 2)` should return "Eagle"
|
||||
`golfScore(4, 2)` debe devolver la cadena `Eagle`
|
||||
|
||||
```js
|
||||
assert(golfScore(4, 2) === 'Eagle');
|
||||
```
|
||||
|
||||
`golfScore(5, 2)` should return "Eagle"
|
||||
`golfScore(5, 2)` debe devolver la cadena `Eagle`
|
||||
|
||||
```js
|
||||
assert(golfScore(5, 2) === 'Eagle');
|
||||
```
|
||||
|
||||
`golfScore(4, 3)` should return "Birdie"
|
||||
`golfScore(4, 3)` debe devolver la cadena `Birdie`
|
||||
|
||||
```js
|
||||
assert(golfScore(4, 3) === 'Birdie');
|
||||
```
|
||||
|
||||
`golfScore(4, 4)` should return "Par"
|
||||
`golfScore(4, 4)` debe devolver la cadena `Par`
|
||||
|
||||
```js
|
||||
assert(golfScore(4, 4) === 'Par');
|
||||
```
|
||||
|
||||
`golfScore(1, 1)` should return "Hole-in-one!"
|
||||
`golfScore(1, 1)` debe devolver la cadena `Hole-in-one!`
|
||||
|
||||
```js
|
||||
assert(golfScore(1, 1) === 'Hole-in-one!');
|
||||
```
|
||||
|
||||
`golfScore(5, 5)` should return "Par"
|
||||
`golfScore(5, 5)` debe devolver la cadena `Par`
|
||||
|
||||
```js
|
||||
assert(golfScore(5, 5) === 'Par');
|
||||
```
|
||||
|
||||
`golfScore(4, 5)` should return "Bogey"
|
||||
`golfScore(4, 5)` debe devolver la cadena `Bogey`
|
||||
|
||||
```js
|
||||
assert(golfScore(4, 5) === 'Bogey');
|
||||
```
|
||||
|
||||
`golfScore(4, 6)` should return "Double Bogey"
|
||||
`golfScore(4, 6)` debe devolver la cadena `Double Bogey`
|
||||
|
||||
```js
|
||||
assert(golfScore(4, 6) === 'Double Bogey');
|
||||
```
|
||||
|
||||
`golfScore(4, 7)` should return "Go Home!"
|
||||
`golfScore(4, 7)` debe devolver la cadena `Go Home!`
|
||||
|
||||
```js
|
||||
assert(golfScore(4, 7) === 'Go Home!');
|
||||
```
|
||||
|
||||
`golfScore(5, 9)` should return "Go Home!"
|
||||
`golfScore(5, 9)` debe devolver la cadena `Go Home!`
|
||||
|
||||
```js
|
||||
assert(golfScore(5, 9) === 'Go Home!');
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244ac
|
||||
title: Increment a Number with JavaScript
|
||||
title: Incrementa un número con JavaScript
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/ca8GLT9'
|
||||
forumTopicId: 18201
|
||||
@ -9,30 +9,29 @@ dashedName: increment-a-number-with-javascript
|
||||
|
||||
# --description--
|
||||
|
||||
You can easily <dfn>increment</dfn> or add one to a variable with the `++` operator.
|
||||
Puedes fácilmente <dfn>incrementar</dfn> o sumar uno a una variable con el operador `++`.
|
||||
|
||||
`i++;`
|
||||
|
||||
is the equivalent of
|
||||
es equivalente a
|
||||
|
||||
`i = i + 1;`
|
||||
|
||||
**Note**
|
||||
The entire line becomes `i++;`, eliminating the need for the equal sign.
|
||||
**Nota:** Toda la línea se convierte en `i++;`, eliminando la necesidad del signo de igualdad.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Change the code to use the `++` operator on `myVar`.
|
||||
Cambia el código para usar el operador `++` en `myVar`.
|
||||
|
||||
# --hints--
|
||||
|
||||
`myVar` should equal `88`.
|
||||
`myVar` debe ser igual a `88`.
|
||||
|
||||
```js
|
||||
assert(myVar === 88);
|
||||
```
|
||||
|
||||
You should not use the assignment operator.
|
||||
No debes utilizar el operador de asignación.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -40,13 +39,13 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
You should use the `++` operator.
|
||||
Debes usar el operador `++`.
|
||||
|
||||
```js
|
||||
assert(/[+]{2}\s*myVar|myVar\s*[+]{2}/.test(code));
|
||||
```
|
||||
|
||||
You should not change code above the specified comment.
|
||||
No debes cambiar el código por encima del comentario especificado.
|
||||
|
||||
```js
|
||||
assert(/var myVar = 87;/.test(code));
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244a9
|
||||
title: Initializing Variables with the Assignment Operator
|
||||
title: Inicializa variables con el operador de asignación
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/cWJ4Bfb'
|
||||
forumTopicId: 301171
|
||||
@ -9,19 +9,19 @@ dashedName: initializing-variables-with-the-assignment-operator
|
||||
|
||||
# --description--
|
||||
|
||||
It is common to <dfn>initialize</dfn> a variable to an initial value in the same line as it is declared.
|
||||
Es común <dfn>inicializar</dfn> una variable a un valor inicial en la misma línea que es declarada.
|
||||
|
||||
`var myVar = 0;`
|
||||
|
||||
Creates a new variable called `myVar` and assigns it an initial value of `0`.
|
||||
Crea una nueva variable llamada `myVar` y le asigna un valor inicial de `0`.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Define a variable `a` with `var` and initialize it to a value of `9`.
|
||||
Define una variable `a` con `var` e inicialízala con un valor de `9`.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should initialize `a` to a value of `9`.
|
||||
Debes inicializar `a` con un valor de `9`.
|
||||
|
||||
```js
|
||||
assert(/var\s+a\s*=\s*9(\s*;?\s*)$/.test(code));
|
||||
@ -36,7 +36,9 @@ if(typeof a !== 'undefined') {(function(a){return "a = " + a;})(a);} else { (fun
|
||||
```
|
||||
|
||||
## --seed-contents--
|
||||
|
||||
```js
|
||||
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244db
|
||||
title: Introducing Else If Statements
|
||||
title: Introducción a las sentencias "Else If"
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/caeJ2hm'
|
||||
forumTopicId: 18206
|
||||
@ -9,7 +9,7 @@ dashedName: introducing-else-if-statements
|
||||
|
||||
# --description--
|
||||
|
||||
If you have multiple conditions that need to be addressed, you can chain `if` statements together with `else if` statements.
|
||||
Si tienes múltiples condiciones que necesitan ser resueltas, puedes encadenar sentencias `if` junto con sentencias `else if`.
|
||||
|
||||
```js
|
||||
if (num > 15) {
|
||||
@ -23,23 +23,23 @@ if (num > 15) {
|
||||
|
||||
# --instructions--
|
||||
|
||||
Convert the logic to use `else if` statements.
|
||||
Transforma la lógica para utilizar la sentencia `else if`.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should have at least two `else` statements
|
||||
Debes tener al menos dos sentencias `else`
|
||||
|
||||
```js
|
||||
assert(code.match(/else/g).length > 1);
|
||||
```
|
||||
|
||||
You should have at least two `if` statements
|
||||
Debes tener al menos dos sentencias `if`
|
||||
|
||||
```js
|
||||
assert(code.match(/if/g).length > 1);
|
||||
```
|
||||
|
||||
You should have closing and opening curly braces for each `if else` code block.
|
||||
Debes utilizar llaves de apertura y cierre para cada bloque de código `if else`.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -49,31 +49,31 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
`testElseIf(0)` should return "Smaller than 5"
|
||||
`testElseIf(0)` debe devolver la cadena `Smaller than 5`
|
||||
|
||||
```js
|
||||
assert(testElseIf(0) === 'Smaller than 5');
|
||||
```
|
||||
|
||||
`testElseIf(5)` should return "Between 5 and 10"
|
||||
`testElseIf(5)` debe devolver la cadena `Between 5 and 10`
|
||||
|
||||
```js
|
||||
assert(testElseIf(5) === 'Between 5 and 10');
|
||||
```
|
||||
|
||||
`testElseIf(7)` should return "Between 5 and 10"
|
||||
`testElseIf(7)` debe devolver la cadena `Between 5 and 10`
|
||||
|
||||
```js
|
||||
assert(testElseIf(7) === 'Between 5 and 10');
|
||||
```
|
||||
|
||||
`testElseIf(10)` should return "Between 5 and 10"
|
||||
`testElseIf(10)` debe devolver la cadena `Between 5 and 10`
|
||||
|
||||
```js
|
||||
assert(testElseIf(10) === 'Between 5 and 10');
|
||||
```
|
||||
|
||||
`testElseIf(12)` should return "Greater than 10"
|
||||
`testElseIf(12)` debe devolver la cadena `Greater than 10`
|
||||
|
||||
```js
|
||||
assert(testElseIf(12) === 'Greater than 10');
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244da
|
||||
title: Introducing Else Statements
|
||||
title: Introducción a las sentencias "Else"
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/cek4Efq'
|
||||
forumTopicId: 18207
|
||||
@ -9,7 +9,7 @@ dashedName: introducing-else-statements
|
||||
|
||||
# --description--
|
||||
|
||||
When a condition for an `if` statement is true, the block of code following it is executed. What about when that condition is false? Normally nothing would happen. With an `else` statement, an alternate block of code can be executed.
|
||||
Cuando la condición en una sentencia `if` es verdadera, se ejecutará el bloque de código que va a continuación. ¿Qué sucede cuando la condición es falsa? Normalmente no debería ocurrir nada. Con la sentencia `else`, se puede ejecutar un bloque alternativo de código.
|
||||
|
||||
```js
|
||||
if (num > 10) {
|
||||
@ -21,47 +21,47 @@ if (num > 10) {
|
||||
|
||||
# --instructions--
|
||||
|
||||
Combine the `if` statements into a single `if/else` statement.
|
||||
Combina la sentencia `if` en una sola sentencia `if/else`.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should only have one `if` statement in the editor
|
||||
Sólo debes tener una sentencia `if` en el editor
|
||||
|
||||
```js
|
||||
assert(code.match(/if/g).length === 1);
|
||||
```
|
||||
|
||||
You should use an `else` statement
|
||||
Debes usar una sentencia `else`
|
||||
|
||||
```js
|
||||
assert(/else/g.test(code));
|
||||
```
|
||||
|
||||
`testElse(4)` should return "5 or Smaller"
|
||||
`testElse(4)` debe devolver la cadena `5 or Smaller`
|
||||
|
||||
```js
|
||||
assert(testElse(4) === '5 or Smaller');
|
||||
```
|
||||
|
||||
`testElse(5)` should return "5 or Smaller"
|
||||
`testElse(5)` debe devolver la cadena `5 or Smaller`
|
||||
|
||||
```js
|
||||
assert(testElse(5) === '5 or Smaller');
|
||||
```
|
||||
|
||||
`testElse(6)` should return "Bigger than 5"
|
||||
`testElse(6)` debe devolver la cadena `Bigger than 5`
|
||||
|
||||
```js
|
||||
assert(testElse(6) === 'Bigger than 5');
|
||||
```
|
||||
|
||||
`testElse(10)` should return "Bigger than 5".
|
||||
`testElse(10)` debe devolver la cadena `Bigger than 5`
|
||||
|
||||
```js
|
||||
assert(testElse(10) === 'Bigger than 5');
|
||||
```
|
||||
|
||||
You should not change the code above or below the specified comments.
|
||||
No debes cambiar el código por encima o por debajo de los comentarios especificados.
|
||||
|
||||
```js
|
||||
assert(/var result = "";/.test(code) && /return result;/.test(code));
|
||||
|
Reference in New Issue
Block a user