chore(i8n,curriculum): processed translations (#41496)
Co-authored-by: Crowdin Bot <support+bot@crowdin.com>
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244df
|
||||
title: Multiple Identical Options in Switch Statements
|
||||
title: Múltiples opciones idénticas en las declaraciones "switch"
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/cdBKWCV'
|
||||
forumTopicId: 18242
|
||||
@ -9,7 +9,7 @@ dashedName: multiple-identical-options-in-switch-statements
|
||||
|
||||
# --description--
|
||||
|
||||
If the `break` statement is omitted from a `switch` statement's `case`, the following `case` statement(s) are executed until a `break` is encountered. If you have multiple inputs with the same output, you can represent them in a `switch` statement like this:
|
||||
Si la sentencia `break` es omitida en un caso (`case`) de una sentencia `switch`, las siguientes sentencias `case` serán ejecutadas hasta encontrar un `break`. Si tienes múltiples entradas con la misma salida, puedes representarlas en una sentencia `switch` como esta:
|
||||
|
||||
```js
|
||||
var result = "";
|
||||
@ -24,81 +24,80 @@ switch(val) {
|
||||
}
|
||||
```
|
||||
|
||||
Cases for 1, 2, and 3 will all produce the same result.
|
||||
Los casos 1, 2 y 3 producirán el mismo resultado.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Write a switch statement to set `answer` for the following ranges:
|
||||
`1-3` - "Low"
|
||||
`4-6` - "Mid"
|
||||
`7-9` - "High"
|
||||
Escribe una declaración switch para establecer `answer` con los siguientes rangos:
|
||||
`1-3` - `Low`
|
||||
`4-6` - `Mid`
|
||||
`7-9` - `High`
|
||||
|
||||
**Note**
|
||||
You will need to have a `case` statement for each number in the range.
|
||||
**Nota:** Necesitarás tener un `case` para cada número dentro del rango.
|
||||
|
||||
# --hints--
|
||||
|
||||
`sequentialSizes(1)` should return "Low"
|
||||
`sequentialSizes(1)` debe devolver la cadena `Low`
|
||||
|
||||
```js
|
||||
assert(sequentialSizes(1) === 'Low');
|
||||
```
|
||||
|
||||
`sequentialSizes(2)` should return "Low"
|
||||
`sequentialSizes(2)` debe devolver la cadena `Low`
|
||||
|
||||
```js
|
||||
assert(sequentialSizes(2) === 'Low');
|
||||
```
|
||||
|
||||
`sequentialSizes(3)` should return "Low"
|
||||
`sequentialSizes(3)` debe devolver la cadena `Low`
|
||||
|
||||
```js
|
||||
assert(sequentialSizes(3) === 'Low');
|
||||
```
|
||||
|
||||
`sequentialSizes(4)` should return "Mid"
|
||||
`sequentialSizes(4)` debe devolver la cadena `Mid`
|
||||
|
||||
```js
|
||||
assert(sequentialSizes(4) === 'Mid');
|
||||
```
|
||||
|
||||
`sequentialSizes(5)` should return "Mid"
|
||||
`sequentialSizes(5)` debe devolver la cadena `Mid`
|
||||
|
||||
```js
|
||||
assert(sequentialSizes(5) === 'Mid');
|
||||
```
|
||||
|
||||
`sequentialSizes(6)` should return "Mid"
|
||||
`sequentialSizes(6)` debe devolver la cadena `Mid`
|
||||
|
||||
```js
|
||||
assert(sequentialSizes(6) === 'Mid');
|
||||
```
|
||||
|
||||
`sequentialSizes(7)` should return "High"
|
||||
`sequentialSizes(7)` debe devolver la cadena `High`
|
||||
|
||||
```js
|
||||
assert(sequentialSizes(7) === 'High');
|
||||
```
|
||||
|
||||
`sequentialSizes(8)` should return "High"
|
||||
`sequentialSizes(8)` debe devolver la cadena `High`
|
||||
|
||||
```js
|
||||
assert(sequentialSizes(8) === 'High');
|
||||
```
|
||||
|
||||
`sequentialSizes(9)` should return "High"
|
||||
`sequentialSizes(9)` debe devolver la cadena `High`
|
||||
|
||||
```js
|
||||
assert(sequentialSizes(9) === 'High');
|
||||
```
|
||||
|
||||
You should not use any `if` or `else` statements
|
||||
No debes utilizar las sentencias `if` o `else`
|
||||
|
||||
```js
|
||||
assert(!/else/g.test(code) || !/if/g.test(code));
|
||||
```
|
||||
|
||||
You should have nine `case` statements
|
||||
Debes tener nueve sentencias `case`
|
||||
|
||||
```js
|
||||
assert(code.match(/case/g).length === 9);
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244cf
|
||||
title: Record Collection
|
||||
title: Colección de discos
|
||||
challengeType: 1
|
||||
forumTopicId: 18261
|
||||
dashedName: record-collection
|
||||
@ -8,21 +8,21 @@ dashedName: record-collection
|
||||
|
||||
# --description--
|
||||
|
||||
You are given a JSON object representing a part of your musical album collection. Each album has a unique id number as its key and several other properties. Not all albums have complete information.
|
||||
Se te da un objeto JSON que representa una parte de tu colección de álbumes musicales. Cada álbum tiene un número de id único como clave y varias otras propiedades. No todos los álbumes tienen una información completa.
|
||||
|
||||
You start with an `updateRecords` function that takes an object like `collection`, an `id`, a `prop` (like `artist` or `tracks`), and a `value`. Complete the function using the rules below to modify the object passed to the function.
|
||||
Empiezas con una función `updateRecords` el cual toma un objeto `collection`, un `id`, una `prop` (como `artist` o `tracks`), y un `value`. Completa la función usando las reglas siguientes para modificar el objeto pasado a la función.
|
||||
|
||||
- Your function must always return the entire object.
|
||||
- If `prop` isn't `tracks` and `value` isn't an empty string, update or set that album's `prop` to `value`.
|
||||
- If `prop` is `tracks` but the album doesn't have a `tracks` property, create an empty array and add `value` to it.
|
||||
- If `prop` is `tracks` and `value` isn't an empty string, add `value` to the end of the album's existing `tracks` array.
|
||||
- If `value` is an empty string, delete the given `prop` property from the album.
|
||||
- Tu función siempre debe devolver el objeto completo.
|
||||
- Si `prop` no es `tracks` y `value` no es una cadena vacía, actualiza o establece la propiedad `prop` del album a `value`.
|
||||
- Si `prop` es `tracks` pero el álbum no tiene una propiedad `tracks`, crea un arreglo vacío y agrégale `value` a él.
|
||||
- Si `prop` es `tracks` y `value` no es una cadena vacía, agrega `value` al final del arreglo de `tracks` existentes del álbum.
|
||||
- Si `value` es una cadena vacía, elimina esa propiedad `prop` del álbum.
|
||||
|
||||
**Note:** A copy of the `collection` object is used for the tests.
|
||||
**Nota:** Una copia del objeto `collection` es usada para las pruebas.
|
||||
|
||||
# --hints--
|
||||
|
||||
After `updateRecords(collection, 5439, "artist", "ABBA")`, `artist` should be `ABBA`
|
||||
Después de `updateRecords(collection, 5439, "artist", "ABBA")`, `artist` debe ser la cadena `ABBA`
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -31,7 +31,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
After `updateRecords(collection, 5439, "tracks", "Take a Chance on Me")`, `tracks` should have `Take a Chance on Me` as the last element.
|
||||
Después de `updateRecords(collection, 5439, "tracks", "Take a Chance on Me")`, `tracks` debe tener la cadena `Take a Chance on Me` como último elemento.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -41,14 +41,14 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
After `updateRecords(collection, 2548, "artist", "")`, `artist` should not be set
|
||||
Después de `updateRecords(collection, 2548, "artist", "")`, `artist` no debe establecerse
|
||||
|
||||
```js
|
||||
updateRecords(_recordCollection, 2548, 'artist', '');
|
||||
assert(!_recordCollection[2548].hasOwnProperty('artist'));
|
||||
```
|
||||
|
||||
After `updateRecords(collection, 1245, "tracks", "Addicted to Love")`, `tracks` should have `Addicted to Love` as the last element.
|
||||
Después de `updateRecords(collection, 1245, "tracks", "Addicted to Love")`, `tracks` debe tener la cadena `Addicted to Love` como último elemento.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -58,7 +58,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
After `updateRecords(collection, 2468, "tracks", "Free")`, `tracks` should have `1999` as the first element.
|
||||
Después de `updateRecords(collection, 2468, "tracks", "Free")`, `tracks` debe tener la cadena `1999` como primer elemento.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -68,14 +68,14 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
After `updateRecords(collection, 2548, "tracks", "")`, `tracks` should not be set
|
||||
Después de `updateRecords(collection, 2548, "tracks", "")`, `tracks` no debe establecerse
|
||||
|
||||
```js
|
||||
updateRecords(_recordCollection, 2548, 'tracks', '');
|
||||
assert(!_recordCollection[2548].hasOwnProperty('tracks'));
|
||||
```
|
||||
|
||||
After `updateRecords(collection, 1245, "albumTitle", "Riptide")`, `albumTitle` should be `Riptide`
|
||||
Después de `updateRecords(collection, 1245, "albumTitle", "Riptide")`, `albumTitle` debe ser la cadena `Riptide`
|
||||
|
||||
```js
|
||||
assert(
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244e0
|
||||
title: Replacing If Else Chains with Switch
|
||||
title: Reemplazando cadenas de "If Else" por "Switch"
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/c3JE8fy'
|
||||
forumTopicId: 18266
|
||||
@ -9,7 +9,7 @@ dashedName: replacing-if-else-chains-with-switch
|
||||
|
||||
# --description--
|
||||
|
||||
If you have many options to choose from, a `switch` statement can be easier to write than many chained `if`/`else if` statements. The following:
|
||||
Si tienes muchas opciones entre las que elegir, una sentencia `switch` puede ser más fácil de escribir que muchas sentencias `if`/`else if` encadenadas. Lo siguiente:
|
||||
|
||||
```js
|
||||
if (val === 1) {
|
||||
@ -21,7 +21,7 @@ if (val === 1) {
|
||||
}
|
||||
```
|
||||
|
||||
can be replaced with:
|
||||
puede reemplazarse por:
|
||||
|
||||
```js
|
||||
switch(val) {
|
||||
@ -38,65 +38,65 @@ switch(val) {
|
||||
|
||||
# --instructions--
|
||||
|
||||
Change the chained `if`/`else if` statements into a `switch` statement.
|
||||
Cambia la cadena de sentencias `if`/`else if` por una sentencia `switch`.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should not use any `else` statements anywhere in the editor
|
||||
No debes utilizar sentencias `else` en ningún lugar en el editor
|
||||
|
||||
```js
|
||||
assert(!/else/g.test(code));
|
||||
```
|
||||
|
||||
You should not use any `if` statements anywhere in the editor
|
||||
No debes utilizar sentencias `if` en ningún lugar en el editor
|
||||
|
||||
```js
|
||||
assert(!/if/g.test(code));
|
||||
```
|
||||
|
||||
You should have at least four `break` statements
|
||||
Debes tener al menos cuatro sentencias `break`
|
||||
|
||||
```js
|
||||
assert(code.match(/break/g).length >= 4);
|
||||
```
|
||||
|
||||
`chainToSwitch("bob")` should be "Marley"
|
||||
`chainToSwitch("bob")` debe ser la cadena `Marley`
|
||||
|
||||
```js
|
||||
assert(chainToSwitch('bob') === 'Marley');
|
||||
```
|
||||
|
||||
`chainToSwitch(42)` should be "The Answer"
|
||||
`chainToSwitch(42)` debe ser la cadena `The Answer`
|
||||
|
||||
```js
|
||||
assert(chainToSwitch(42) === 'The Answer');
|
||||
```
|
||||
|
||||
`chainToSwitch(1)` should be "There is no #1"
|
||||
`chainToSwitch(1)` debe ser la cadena `There is no #1`
|
||||
|
||||
```js
|
||||
assert(chainToSwitch(1) === 'There is no #1');
|
||||
```
|
||||
|
||||
`chainToSwitch(99)` should be "Missed me by this much!"
|
||||
`chainToSwitch(99)` debe ser la cadena `Missed me by this much!`
|
||||
|
||||
```js
|
||||
assert(chainToSwitch(99) === 'Missed me by this much!');
|
||||
```
|
||||
|
||||
`chainToSwitch(7)` should be "Ate Nine"
|
||||
`chainToSwitch(7)` debe ser la cadena `Ate Nine`
|
||||
|
||||
```js
|
||||
assert(chainToSwitch(7) === 'Ate Nine');
|
||||
```
|
||||
|
||||
`chainToSwitch("John")` should be "" (empty string)
|
||||
`chainToSwitch("John")` debe ser `""` (cadena vacía)
|
||||
|
||||
```js
|
||||
assert(chainToSwitch('John') === '');
|
||||
```
|
||||
|
||||
`chainToSwitch(156)` should be "" (empty string)
|
||||
`chainToSwitch(156)` debe ser `""` (cadena vacía)
|
||||
|
||||
```js
|
||||
assert(chainToSwitch(156) === '');
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244dd
|
||||
title: Selecting from Many Options with Switch Statements
|
||||
title: Seleccionando entre muchas opciones con declaración switch
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/c4mv4fm'
|
||||
forumTopicId: 18277
|
||||
@ -9,9 +9,9 @@ dashedName: selecting-from-many-options-with-switch-statements
|
||||
|
||||
# --description--
|
||||
|
||||
If you have many options to choose from, use a <dfn>switch</dfn> statement. A `switch` statement tests a value and can have many <dfn>case</dfn> statements which define various possible values. Statements are executed from the first matched `case` value until a `break` is encountered.
|
||||
Si tienes muchas opciones para elegir, usa una declaración <dfn>switch</dfn>. Una sentencia `switch` prueba un valor y puede tener muchas sentencias <dfn>case</dfn> que definen varios valores posibles. Las sentencias se ejecutan desde el primer valor `case` coincidente hasta que se encuentra un `break`.
|
||||
|
||||
Here is an example of a `switch` statement:
|
||||
Aquí hay un ejemplo de una declaración `switch`:
|
||||
|
||||
```js
|
||||
switch(lowercaseLetter) {
|
||||
@ -24,49 +24,49 @@ switch(lowercaseLetter) {
|
||||
}
|
||||
```
|
||||
|
||||
`case` values are tested with strict equality (`===`). The `break` tells JavaScript to stop executing statements. If the `break` is omitted, the next statement will be executed.
|
||||
Los valores en las sentencias `case` se prueban con igualdad estricta (`===`). El `break` le dice a JavaScript que deje de ejecutar declaraciones. Si se omite `break`, se ejecutara la siguiente sentencia.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Write a switch statement which tests `val` and sets `answer` for the following conditions:
|
||||
`1` - "alpha"
|
||||
`2` - "beta"
|
||||
`3` - "gamma"
|
||||
`4` - "delta"
|
||||
Escribe una declaración switch que pruebe `val` y establezca `answer` con las siguientes condiciones:
|
||||
`1` - `alpha`
|
||||
`2` - `beta`
|
||||
`3` - `gamma`
|
||||
`4` - `delta`
|
||||
|
||||
# --hints--
|
||||
|
||||
`caseInSwitch(1)` should have a value of "alpha"
|
||||
`caseInSwitch(1)` debe tener una cadena con valor `alpha`
|
||||
|
||||
```js
|
||||
assert(caseInSwitch(1) === 'alpha');
|
||||
```
|
||||
|
||||
`caseInSwitch(2)` should have a value of "beta"
|
||||
`caseInSwitch(2)` debe tener una cadena con valor `beta`
|
||||
|
||||
```js
|
||||
assert(caseInSwitch(2) === 'beta');
|
||||
```
|
||||
|
||||
`caseInSwitch(3)` should have a value of "gamma"
|
||||
`caseInSwitch(3)` debe tener una cadena con valor `gamma`
|
||||
|
||||
```js
|
||||
assert(caseInSwitch(3) === 'gamma');
|
||||
```
|
||||
|
||||
`caseInSwitch(4)` should have a value of "delta"
|
||||
`caseInSwitch(4)` debe tener una cadena con valor `delta`
|
||||
|
||||
```js
|
||||
assert(caseInSwitch(4) === 'delta');
|
||||
```
|
||||
|
||||
You should not use any `if` or `else` statements
|
||||
No debes usar ninguna sentencia `if` o `else`
|
||||
|
||||
```js
|
||||
assert(!/else/g.test(code) || !/if/g.test(code));
|
||||
```
|
||||
|
||||
You should have at least 3 `break` statements
|
||||
Debes tener al menos 3 declaraciones `break`
|
||||
|
||||
```js
|
||||
assert(code.match(/break/g).length > 2);
|
||||
|
@ -13,15 +13,12 @@ Con las variables de arreglos (`array`) de JavaScript, podemos almacenar varios
|
||||
|
||||
Inicias una declaración de arreglo con un corchete de apertura, lo terminas con un corchete de cierre, y pones una coma entre cada entrada, de esta forma:
|
||||
|
||||
`var sandwich = ["peanut butter", "jelly", "bread"]`.
|
||||
`var sandwich = ["peanut butter", "jelly", "bread"]`
|
||||
|
||||
# --instructions--
|
||||
|
||||
Modifica el nuevo arreglo `myArray` para que contenga tanto una `string` como un `number` (en ese orden).
|
||||
|
||||
**Sugerencia**
|
||||
Consulta el código de ejemplo en el editor de texto si te quedas atascado.
|
||||
|
||||
# --hints--
|
||||
|
||||
`myArray` debe ser un arreglo (`array`).
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: cf1111c1c11feddfaeb4bdef
|
||||
title: Subtract One Number from Another with JavaScript
|
||||
title: Resta un número de otro con JavaScript
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/cP3yQtk'
|
||||
forumTopicId: 18314
|
||||
@ -9,29 +9,30 @@ dashedName: subtract-one-number-from-another-with-javascript
|
||||
|
||||
# --description--
|
||||
|
||||
We can also subtract one number from another.
|
||||
También podemos restar un número de otro.
|
||||
|
||||
JavaScript uses the `-` symbol for subtraction.
|
||||
JavaScript utiliza el símbolo `-` para restar.
|
||||
|
||||
**Example**
|
||||
**Ejemplo**
|
||||
|
||||
```js
|
||||
myVar = 12 - 6; // assigned 6
|
||||
myVar = 12 - 6;
|
||||
```
|
||||
|
||||
`myVar` tendrá el valor `6`.
|
||||
# --instructions--
|
||||
|
||||
Change the `0` so the difference is `12`.
|
||||
Cambia el `0` para que la diferencia sea `12`.
|
||||
|
||||
# --hints--
|
||||
|
||||
The variable `difference` should be equal to 12.
|
||||
La variable `difference` debe ser igual a 12.
|
||||
|
||||
```js
|
||||
assert(difference === 12);
|
||||
```
|
||||
|
||||
You should only subtract one number from 45.
|
||||
Sólo debes restar un número de 45.
|
||||
|
||||
```js
|
||||
assert(/difference=45-33;?/.test(__helpers.removeWhiteSpace(code)));
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 567af2437cbaa8c51670a16c
|
||||
title: Testing Objects for Properties
|
||||
title: Verifica las propiedades de un objeto
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/c6Wz4ySr'
|
||||
forumTopicId: 18324
|
||||
@ -9,26 +9,28 @@ dashedName: testing-objects-for-properties
|
||||
|
||||
# --description--
|
||||
|
||||
Sometimes it is useful to check if the property of a given object exists or not. We can use the `.hasOwnProperty(propname)` method of objects to determine if that object has the given property name. `.hasOwnProperty()` returns `true` or `false` if the property is found or not.
|
||||
A veces es útil comprobar si existe o no la propiedad de un objeto dado. Podemos utilizar el método `.hasOwnProperty(propname)` para determinar si un objeto tiene una propiedad con ese nombre. `.hasOwnProperty()` devuelve `true` o `false` si se encuentra la propiedad o no.
|
||||
|
||||
**Example**
|
||||
**Por ejemplo**
|
||||
|
||||
```js
|
||||
var myObj = {
|
||||
top: "hat",
|
||||
bottom: "pants"
|
||||
};
|
||||
myObj.hasOwnProperty("top"); // true
|
||||
myObj.hasOwnProperty("middle"); // false
|
||||
myObj.hasOwnProperty("top");
|
||||
myObj.hasOwnProperty("middle");
|
||||
```
|
||||
|
||||
El primer `hasOwnProperty` devuelve `true`, mientras que el segundo devuelve `false`.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Modify the function `checkObj` to test if an object passed to the function (`obj`) contains a specific property (`checkProp`). If the property is found, return that property's value. If not, return `"Not Found"`.
|
||||
Modifica la función `checkObj` para verificar si el objeto `obj` pasado a la función contiene la propiedad `checkProp`. Si la propiedad es encontrada, devuelve el valor de la propiedad. Si no, devuelve `"Not Found"`.
|
||||
|
||||
# --hints--
|
||||
|
||||
`checkObj({gift: "pony", pet: "kitten", bed: "sleigh"}, "gift")` should return `"pony"`.
|
||||
`checkObj({gift: "pony", pet: "kitten", bed: "sleigh"}, "gift")` debe devolver la cadena`pony`.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -36,7 +38,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
`checkObj({gift: "pony", pet: "kitten", bed: "sleigh"}, "pet")` should return `"kitten"`.
|
||||
`checkObj({gift: "pony", pet: "kitten", bed: "sleigh"}, "pet")` debe devolver la cadena `kitten`.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -44,7 +46,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
`checkObj({gift: "pony", pet: "kitten", bed: "sleigh"}, "house")` should return `"Not Found"`.
|
||||
`checkObj({gift: "pony", pet: "kitten", bed: "sleigh"}, "house")` debe devolver la cadena `Not Found`.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -53,19 +55,19 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
`checkObj({city: "Seattle"}, "city")` should return `"Seattle"`.
|
||||
`checkObj({city: "Seattle"}, "city")` debe devolver la cadena `Seattle`.
|
||||
|
||||
```js
|
||||
assert(checkObj({ city: 'Seattle' }, 'city') === 'Seattle');
|
||||
```
|
||||
|
||||
`checkObj({city: "Seattle"}, "district")` should return `"Not Found"`.
|
||||
`checkObj({city: "Seattle"}, "district")` debe devolver la cadena `Not Found`.
|
||||
|
||||
```js
|
||||
assert(checkObj({ city: 'Seattle' }, 'district') === 'Not Found');
|
||||
```
|
||||
|
||||
`checkObj({pet: "kitten", bed: "sleigh"}, "gift")` should return `"Not Found"`.
|
||||
`checkObj({pet: "kitten", bed: "sleigh"}, "gift")` debe devolver la cadena `Not Found`.
|
||||
|
||||
```js
|
||||
assert(checkObj({ pet: 'kitten', bed: 'sleigh' }, 'gift') === 'Not Found');
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244ba
|
||||
title: Understand String Immutability
|
||||
title: Comprende la inmutabilidad de las cadenas
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/cWPVaUR'
|
||||
forumTopicId: 18331
|
||||
@ -9,16 +9,16 @@ dashedName: understand-string-immutability
|
||||
|
||||
# --description--
|
||||
|
||||
In JavaScript, `String` values are <dfn>immutable</dfn>, which means that they cannot be altered once created.
|
||||
En JavaScript, los valores de cadena (`String`) son <dfn>inmutables</dfn>, lo que significa que no pueden ser alterados una vez creados.
|
||||
|
||||
For example, the following code:
|
||||
Por ejemplo, el siguiente código:
|
||||
|
||||
```js
|
||||
var myStr = "Bob";
|
||||
myStr[0] = "J";
|
||||
```
|
||||
|
||||
cannot change the value of `myStr` to "Job", because the contents of `myStr` cannot be altered. Note that this does *not* mean that `myStr` cannot be changed, just that the individual characters of a <dfn>string literal</dfn> cannot be changed. The only way to change `myStr` would be to assign it with a new string, like this:
|
||||
no puede cambiar el valor de `myStr` a `Job`, porque el contenido de `myStr` no puede ser alterado. Ten en cuenta que esto *no* significa que `myStr` no puede cambiarse, solo que los caracteres individuales de una <dfn>cadena literal</dfn> no pueden ser cambiados. La única forma de cambiar `myStr` sería asignarla con una nueva cadena, como esta:
|
||||
|
||||
```js
|
||||
var myStr = "Bob";
|
||||
@ -27,17 +27,17 @@ myStr = "Job";
|
||||
|
||||
# --instructions--
|
||||
|
||||
Correct the assignment to `myStr` so it contains the string value of `Hello World` using the approach shown in the example above.
|
||||
Corrige la asignación de `myStr` para que contenga el valor de cadena `Hello World` usando el método mostrado en el ejemplo anterior.
|
||||
|
||||
# --hints--
|
||||
|
||||
`myStr` should have a value of `Hello World`.
|
||||
`myStr` debe tener una cadena con valor `Hello World`.
|
||||
|
||||
```js
|
||||
assert(myStr === 'Hello World');
|
||||
```
|
||||
|
||||
You should not change the code above the specified comment.
|
||||
No debes cambiar el código por encima del comentario especificado.
|
||||
|
||||
```js
|
||||
assert(/myStr = "Jello World"/.test(code));
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: bd7123c9c441eddfaeb5bdef
|
||||
title: Understanding Boolean Values
|
||||
title: Comprende los valores booleanos
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/c9Me8t4'
|
||||
forumTopicId: 301176
|
||||
@ -9,24 +9,23 @@ dashedName: understanding-boolean-values
|
||||
|
||||
# --description--
|
||||
|
||||
Another data type is the <dfn>Boolean</dfn>. `Booleans` may only be one of two values: `true` or `false`. They are basically little on-off switches, where `true` is "on" and `false` is "off." These two states are mutually exclusive.
|
||||
Otro tipo de datos es el <dfn>Booleano</dfn>. Los booleanos solo pueden ser uno de dos valores: `true` (verdadero) o `false` (falso). Básicamente son pequeños interruptores de encendido, donde `true` es encendido y `false` es apagado. Estos dos estados se excluyen mutuamente.
|
||||
|
||||
**Note**
|
||||
`Boolean` values are never written with quotes. The `strings` `"true"` and `"false"` are not `Boolean` and have no special meaning in JavaScript.
|
||||
**Nota** Los valores del tipo booleano nunca se escriben con comillas. Las cadenas `"true"` y `"false"` no son booleanos y no tienen ningún significado especial en JavaScript.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Modify the `welcomeToBooleans` function so that it returns `true` instead of `false` when the run button is clicked.
|
||||
Modifica la función `welcomeToBooleans` para que devuelva `true` en lugar de `false` cuando se haga clic en el botón de ejecución.
|
||||
|
||||
# --hints--
|
||||
|
||||
The `welcomeToBooleans()` function should return a boolean (true/false) value.
|
||||
La función `welcomeToBooleans()` debe devolver un valor booleano (`true` o `false`).
|
||||
|
||||
```js
|
||||
assert(typeof welcomeToBooleans() === 'boolean');
|
||||
```
|
||||
|
||||
`welcomeToBooleans()` should return true.
|
||||
`welcomeToBooleans()` debe devolver `true`.
|
||||
|
||||
```js
|
||||
assert(welcomeToBooleans() === true);
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244ab
|
||||
title: Comprender la sensibilidad de mayúsculas en las variables
|
||||
title: Comprendiendo la sensibilidad de mayúsculas en las variables
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/cd6GDcD'
|
||||
forumTopicId: 18334
|
||||
@ -27,8 +27,9 @@ var thisVariableNameIsSoLong;
|
||||
|
||||
# --instructions--
|
||||
|
||||
Modifica las declaraciones y asignaciones existentes para que sus nombres usen <dfn>camelCase</dfn>.
|
||||
No crees nuevas variables.
|
||||
Modifica las declaraciones y asignaciones existentes para que sus nombres usen <dfn>camelCase</dfn>.
|
||||
|
||||
No crees ninguna variable nueva.
|
||||
|
||||
# --hints--
|
||||
|
||||
@ -38,7 +39,7 @@ No crees nuevas variables.
|
||||
assert(typeof studlyCapVar !== 'undefined' && studlyCapVar === 10);
|
||||
```
|
||||
|
||||
`properCamelCase` debe definirse y tener un valor de `"A String"`.
|
||||
`properCamelCase` debe definirse y tener una cadena con valor `A String`.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -46,7 +47,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
`titleCaseOver` debe definirse y tener un valor de `9000`.
|
||||
`titleCaseOver` debe definirse y tener una cadena con valor `9000`.
|
||||
|
||||
```js
|
||||
assert(typeof titleCaseOver !== 'undefined' && titleCaseOver === 9000);
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 598e8944f009e646fc236146
|
||||
title: Understanding Undefined Value returned from a Function
|
||||
title: Comprendiendo el valor indefinido devuelto por una función
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/ce2p7cL'
|
||||
forumTopicId: 301177
|
||||
@ -9,45 +9,45 @@ dashedName: understanding-undefined-value-returned-from-a-function
|
||||
|
||||
# --description--
|
||||
|
||||
A function can include the `return` statement but it does not have to. In the case that the function doesn't have a `return` statement, when you call it, the function processes the inner code but the returned value is `undefined`.
|
||||
Una función puede incluir la declaración de devolución (`return`) pero no tiene por qué hacerlo. En el caso de que la función no tenga una declaración de devolución (`return`), cuando la llames, la función procesa el código interno, pero el valor devuelto es `undefined` (indefinido).
|
||||
|
||||
**Example**
|
||||
**Ejemplo**
|
||||
|
||||
```js
|
||||
var sum = 0;
|
||||
function addSum(num) {
|
||||
sum = sum + num;
|
||||
}
|
||||
addSum(3); // sum will be modified but returned value is undefined
|
||||
addSum(3);
|
||||
```
|
||||
|
||||
`addSum` is a function without a `return` statement. The function will change the global `sum` variable but the returned value of the function is `undefined`.
|
||||
`addSum` es una función sin una declaración de devolución (`return`). La función cambiará la variable global `sum` pero el valor devuelto de la función es `undefined`.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Create a function `addFive` without any arguments. This function adds 5 to the `sum` variable, but its returned value is `undefined`.
|
||||
Crea una función `addFive` sin ningún argumento. Esta función suma 5 a la variable `sum`, pero su valor devuelto es `undefined`.
|
||||
|
||||
# --hints--
|
||||
|
||||
`addFive` should be a function.
|
||||
`addFive` debe ser una función.
|
||||
|
||||
```js
|
||||
assert(typeof addFive === 'function');
|
||||
```
|
||||
|
||||
Once both functions have ran, the `sum` should be equal to 8.
|
||||
Una vez que ambas funciones hayan sido ejecutadas, la suma (`sum`) debe ser igual a `8`.
|
||||
|
||||
```js
|
||||
assert(sum === 8);
|
||||
```
|
||||
|
||||
Returned value from `addFive` should be `undefined`.
|
||||
El valor devuelto por `addFive` debe ser `undefined`.
|
||||
|
||||
```js
|
||||
assert(addFive() === undefined);
|
||||
```
|
||||
|
||||
Inside the `addFive` function, you should add `5` to the `sum` variable.
|
||||
Dentro de la función `addFive`, debes sumar `5` a la variable `sum`.
|
||||
|
||||
```js
|
||||
assert(
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244aa
|
||||
title: Understanding Uninitialized Variables
|
||||
title: Comprendiendo las variables no inicializadas
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/cBa2JAL'
|
||||
forumTopicId: 18335
|
||||
@ -9,33 +9,33 @@ dashedName: understanding-uninitialized-variables
|
||||
|
||||
# --description--
|
||||
|
||||
When JavaScript variables are declared, they have an initial value of `undefined`. If you do a mathematical operation on an `undefined` variable your result will be `NaN` which means <dfn>"Not a Number"</dfn>. If you concatenate a string with an `undefined` variable, you will get a literal <dfn>string</dfn> of `"undefined"`.
|
||||
Cuando las variables de JavaScript son declaradas, tienen un valor inicial de `undefined` (indefinido). Si haces una operación matemática en una variable `undefined`, tu resultado será `NaN` lo que significa <dfn>"Not a Number"</dfn> (no es un número). Si concatenas una cadena con una variable `undefined`, obtendrás una <dfn>cadena</dfn> literal con valor `undefined`.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Initialize the three variables `a`, `b`, and `c` with `5`, `10`, and `"I am a"` respectively so that they will not be `undefined`.
|
||||
Inicializa las tres variables `a`, `b`, y `c` con `5`, `10` y `"I am a"` respectivamente para que no sean `undefined`.
|
||||
|
||||
# --hints--
|
||||
|
||||
`a` should be defined and evaluated to have the value of `6`.
|
||||
`a` debe ser definido y evaluado para tener el valor de `6`.
|
||||
|
||||
```js
|
||||
assert(typeof a === 'number' && a === 6);
|
||||
```
|
||||
|
||||
`b` should be defined and evaluated to have the value of `15`.
|
||||
`b` debe ser definido y evaluado para tener el valor de `15`.
|
||||
|
||||
```js
|
||||
assert(typeof b === 'number' && b === 15);
|
||||
```
|
||||
|
||||
`c` should not contain `undefined` and should have a value of "I am a String!"
|
||||
`c` no debe contener `undefined` y debe tener una cadena con valor `I am a String!`
|
||||
|
||||
```js
|
||||
assert(!/undefined/.test(c) && c === 'I am a String!');
|
||||
```
|
||||
|
||||
You should not change code below the specified comment.
|
||||
No debes cambiar el código debajo del comentario especificado.
|
||||
|
||||
```js
|
||||
assert(
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 56bbb991ad1ed5201cd392d1
|
||||
title: Updating Object Properties
|
||||
title: Actualizando las propiedades de un objeto
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/c9yEJT4'
|
||||
forumTopicId: 18336
|
||||
@ -9,9 +9,9 @@ dashedName: updating-object-properties
|
||||
|
||||
# --description--
|
||||
|
||||
After you've created a JavaScript object, you can update its properties at any time just like you would update any other variable. You can use either dot or bracket notation to update.
|
||||
Después de haber creado un objeto de JavaScript, puedes actualizar sus propiedades en cualquier momento tal y como actualizarías cualquier otra variable. Puedes utilizar tanto la notación de puntos como la notación de corchetes para actualizar.
|
||||
|
||||
For example, let's look at `ourDog`:
|
||||
Por ejemplo, veamos `ourDog`:
|
||||
|
||||
```js
|
||||
var ourDog = {
|
||||
@ -22,21 +22,21 @@ var ourDog = {
|
||||
};
|
||||
```
|
||||
|
||||
Since he's a particularly happy dog, let's change his name to "Happy Camper". Here's how we update his object's name property: `ourDog.name = "Happy Camper";` or `ourDog["name"] = "Happy Camper";` Now when we evaluate `ourDog.name`, instead of getting "Camper", we'll get his new name, "Happy Camper".
|
||||
Puesto que es un perro particularmente feliz, vamos a cambiar su nombre por la cadena `Happy Camper`. Así es como actualizamos la propiedad del nombre del objeto: `ourDog.name = "Happy Camper";` o `ourDog["name"] = "Happy Camper";`. Ahora cuando evaluamos `ourDog.name`, en lugar de obtener `Camper`, vamos a obtener su nuevo nombre, `Happy Camper`.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Update the `myDog` object's name property. Let's change her name from "Coder" to "Happy Coder". You can use either dot or bracket notation.
|
||||
Actualiza la propiedad nombre del objeto `myDog`. Cambiemos su nombre de `Coder` a `Happy Coder`. Puedes utilizar tanto la notación de puntos como la notación de corchetes.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should update `myDog`'s `"name"` property to equal "Happy Coder".
|
||||
Debes actualizar la propiedad `name` de `myDog` para que sea igual a la cadena `Happy Coder`.
|
||||
|
||||
```js
|
||||
assert(/happy coder/gi.test(myDog.name));
|
||||
```
|
||||
|
||||
You should not edit the `myDog` definition.
|
||||
No debes editar la definición de `myDog`.
|
||||
|
||||
```js
|
||||
assert(/"name": "Coder"/.test(code));
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: bd7123c9c549eddfaeb5bdef
|
||||
title: Use Bracket Notation to Find the First Character in a String
|
||||
title: Utiliza la notación de corchetes para encontrar el primer carácter en una cadena
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/ca8JwhW'
|
||||
forumTopicId: 18341
|
||||
@ -9,34 +9,36 @@ dashedName: use-bracket-notation-to-find-the-first-character-in-a-string
|
||||
|
||||
# --description--
|
||||
|
||||
<dfn>Bracket notation</dfn> is a way to get a character at a specific `index` within a string.
|
||||
La <dfn>notación de corchetes</dfn> es una forma de obtener un carácter en un índice (index) específico dentro de una cadena.
|
||||
|
||||
Most modern programming languages, like JavaScript, don't start counting at 1 like humans do. They start at 0. This is referred to as <dfn>Zero-based</dfn> indexing.
|
||||
La mayoría de lenguajes de programación modernos, como JavaScript, no empiezan a contar desde 1 como lo hacen los humanos. Empiezan desde 0. Esto se conoce como indexación <dfn>basada en cero</dfn>.
|
||||
|
||||
For example, the character at index 0 in the word "Charles" is "C". So if `var firstName = "Charles"`, you can get the value of the first letter of the string by using `firstName[0]`.
|
||||
Por ejemplo, el carácter en el índice 0 de la palabra `Charles` es `C`. Así que si declaramos `var firstName = "Charles"`, puedes obtener el valor de la primera letra de la cadena usando `firstName[0]`.
|
||||
|
||||
Example:
|
||||
Ejemplo:
|
||||
|
||||
```js
|
||||
var firstName = "Charles";
|
||||
var firstLetter = firstName[0]; // firstLetter is "C"
|
||||
var firstLetter = firstName[0];
|
||||
```
|
||||
|
||||
`firstLetter` tendrá una cadena con valor `C`.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Use bracket notation to find the first character in the `lastName` variable and assign it to `firstLetterOfLastName`.
|
||||
Utiliza notación de corchetes para encontrar el primer carácter en la variable `lastName` y asígnalo a `firstLetterOfLastName`.
|
||||
|
||||
**Hint:** Try looking at the example above if you get stuck.
|
||||
**Sugerencia:** Intenta mirar el ejemplo de arriba si te quedas atascado.
|
||||
|
||||
# --hints--
|
||||
|
||||
The `firstLetterOfLastName` variable should have the value of `L`.
|
||||
La variable `firstLetterOfLastName` debe tener el valor de `L`.
|
||||
|
||||
```js
|
||||
assert(firstLetterOfLastName === 'L');
|
||||
```
|
||||
|
||||
You should use bracket notation.
|
||||
Debes usar la notación de corchetes.
|
||||
|
||||
```js
|
||||
assert(code.match(/firstLetterOfLastName\s*?=\s*?lastName\[.*?\]/));
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: bd7123c9c451eddfaeb5bdef
|
||||
title: Utilice la notación de corchete para encontrar el último carácter en una cadena
|
||||
title: Utiliza la notación de corchetes para encontrar el último carácter en una cadena
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/cBZQGcv'
|
||||
forumTopicId: 18342
|
||||
@ -9,7 +9,7 @@ dashedName: use-bracket-notation-to-find-the-last-character-in-a-string
|
||||
|
||||
# --description--
|
||||
|
||||
Con el fin de obtener la última letra de una cadena, puede restar uno a la longitud del texto.
|
||||
Con el fin de obtener la última letra de una cadena, puedes restar uno a la longitud del texto.
|
||||
|
||||
Por ejemplo, si `var firstName = "Charles"`, puedes obtener el valor de la última letra de la cadena usando `firstName[firstName.length - 1]`.
|
||||
|
||||
@ -17,9 +17,11 @@ Ejemplo:
|
||||
|
||||
```js
|
||||
var firstName = "Charles";
|
||||
var lastLetter = firstName[firstName.length - 1]; // lastLetter is "s"
|
||||
var lastLetter = firstName[firstName.length - 1];
|
||||
```
|
||||
|
||||
`lastLetter` tendrá una cadena con valor `s`.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Usa <dfn>notación de corchetes</dfn> para encontrar el último carácter en la variable `lastName`.
|
||||
@ -28,7 +30,7 @@ Usa <dfn>notación de corchetes</dfn> para encontrar el último carácter en la
|
||||
|
||||
# --hints--
|
||||
|
||||
`lastLetterOfLastName` debe ser "e".
|
||||
`lastLetterOfLastName` debe ser la letra `e`.
|
||||
|
||||
```js
|
||||
assert(lastLetterOfLastName === 'e');
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: bd7123c9c450eddfaeb5bdef
|
||||
title: Use Bracket Notation to Find the Nth Character in a String
|
||||
title: Utiliza la notación de corchetes para encontrar el enésimo carácter en una cadena
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/cWPVJua'
|
||||
forumTopicId: 18343
|
||||
@ -9,32 +9,34 @@ dashedName: use-bracket-notation-to-find-the-nth-character-in-a-string
|
||||
|
||||
# --description--
|
||||
|
||||
You can also use <dfn>bracket notation</dfn> to get the character at other positions within a string.
|
||||
También puedes usar <dfn>notación de corchetes</dfn> para obtener el carácter en otras posiciones dentro de una cadena.
|
||||
|
||||
Remember that computers start counting at `0`, so the first character is actually the zeroth character.
|
||||
Recuerda que las computadoras empiezan a contar desde `0`, así que el primer carácter es en realidad el carácter cero.
|
||||
|
||||
Example:
|
||||
Ejemplo:
|
||||
|
||||
```js
|
||||
var firstName = "Ada";
|
||||
var secondLetterOfFirstName = firstName[1]; // secondLetterOfFirstName is "d"
|
||||
var secondLetterOfFirstName = firstName[1];
|
||||
```
|
||||
|
||||
`secondLetterOfFirstName` tendrá una cadena con valor `d`.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Let's try to set `thirdLetterOfLastName` to equal the third letter of the `lastName` variable using bracket notation.
|
||||
Intentemos establecer `thirdLetterOfLastName` (tercera letra del apellido) para que sea igual a la tercera letra de la variable `lastName` usando notación de corchetes.
|
||||
|
||||
**Hint:** Try looking at the example above if you get stuck.
|
||||
**Sugerencia:** Intenta mirar el ejemplo de arriba si te quedas atascado.
|
||||
|
||||
# --hints--
|
||||
|
||||
The `thirdLetterOfLastName` variable should have the value of `v`.
|
||||
La variable `thirdLetterOfLastName` debe tener el valor de `v`.
|
||||
|
||||
```js
|
||||
assert(thirdLetterOfLastName === 'v');
|
||||
```
|
||||
|
||||
You should use bracket notation.
|
||||
Debes usar la notación de corchetes.
|
||||
|
||||
```js
|
||||
assert(code.match(/thirdLetterOfLastName\s*?=\s*?lastName\[.*?\]/));
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: bd7123c9c452eddfaeb5bdef
|
||||
title: Use Bracket Notation to Find the Nth-to-Last Character in a String
|
||||
title: Utiliza la notación de corchetes para encontrar el carácter enésimo final en una cadena
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/cw4vkh9'
|
||||
forumTopicId: 18344
|
||||
@ -9,32 +9,34 @@ dashedName: use-bracket-notation-to-find-the-nth-to-last-character-in-a-string
|
||||
|
||||
# --description--
|
||||
|
||||
You can use the same principle we just used to retrieve the last character in a string to retrieve the Nth-to-last character.
|
||||
Puedes usar el mismo principio que acabamos de usar para recuperar el último carácter de una cadena para recuperar el carácter enésimo final.
|
||||
|
||||
For example, you can get the value of the third-to-last letter of the `var firstName = "Charles"` string by using `firstName[firstName.length - 3]`
|
||||
Por ejemplo, puedes obtener el valor de la antepenúltima letra de la cadena `var firstName = "Charles"` usando `firstName[firstName.length - 3]`
|
||||
|
||||
Example:
|
||||
Ejemplo:
|
||||
|
||||
```js
|
||||
var firstName = "Charles";
|
||||
var thirdToLastLetter = firstName[firstName.length - 3]; // thirdToLastLetter is "l"
|
||||
var thirdToLastLetter = firstName[firstName.length - 3];
|
||||
```
|
||||
|
||||
`thirdToLastLetter` tendrá una cadena con valor `l`.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Use <dfn>bracket notation</dfn> to find the second-to-last character in the `lastName` string.
|
||||
Usa <dfn>notación de corchetes</dfn> para encontrar el penúltimo carácter en la cadena `lastName`.
|
||||
|
||||
**Hint:** Try looking at the example above if you get stuck.
|
||||
**Sugerencia:** Intenta mirar el ejemplo de arriba si te quedas atascado.
|
||||
|
||||
# --hints--
|
||||
|
||||
`secondToLastLetterOfLastName` should be "c".
|
||||
`secondToLastLetterOfLastName` debe ser la letra `c`.
|
||||
|
||||
```js
|
||||
assert(secondToLastLetterOfLastName === 'c');
|
||||
```
|
||||
|
||||
You should use `.length` to get the second last letter.
|
||||
Debes usar `.length` para obtener la penúltima letra.
|
||||
|
||||
```js
|
||||
assert(code.match(/\.length/g).length > 0);
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: cf1111c1c12feddfaeb3bdef
|
||||
title: Use Conditional Logic with If Statements
|
||||
title: Usa lógica condicional con las sentencias "If"
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/cy87mf3'
|
||||
forumTopicId: 18348
|
||||
@ -9,15 +9,15 @@ dashedName: use-conditional-logic-with-if-statements
|
||||
|
||||
# --description--
|
||||
|
||||
`If` statements are used to make decisions in code. The keyword `if` tells JavaScript to execute the code in the curly braces under certain conditions, defined in the parentheses. These conditions are known as `Boolean` conditions and they may only be `true` or `false`.
|
||||
Las sentencias `If` son utilizadas para tomar decisiones en el código. La palabra clave `if` le dice a JavaScript que ejecute el código entre llaves bajo ciertas condiciones, definidas en los paréntesis. Estas condiciones son conocidas como condiciones booleanas (`Boolean`) y sólo pueden ser `true` o `false`.
|
||||
|
||||
When the condition evaluates to `true`, the program executes the statement inside the curly braces. When the Boolean condition evaluates to `false`, the statement inside the curly braces will not execute.
|
||||
Cuando la condición se evalúa como `true`, el programa ejecuta el comando dentro de las llaves. Cuando la condición booleana se evalúa como `false`, la sentencia dentro de las llaves no se ejecutará.
|
||||
|
||||
**Pseudocode**
|
||||
**Pseudocódigo**
|
||||
|
||||
<blockquote>if (<i>condition is true</i>) {<br> <i>statement is executed</i><br>}</blockquote>
|
||||
<blockquote>si (<i>la condición es verdadera</i>) {<br> <i>la sentencia es ejecutada</i><br>}</blockquote>
|
||||
|
||||
**Example**
|
||||
**Ejemplo**
|
||||
|
||||
```js
|
||||
function test (myCondition) {
|
||||
@ -26,43 +26,45 @@ function test (myCondition) {
|
||||
}
|
||||
return "It was false";
|
||||
}
|
||||
test(true); // returns "It was true"
|
||||
test(false); // returns "It was false"
|
||||
test(true);
|
||||
test(false);
|
||||
```
|
||||
|
||||
When `test` is called with a value of `true`, the `if` statement evaluates `myCondition` to see if it is `true` or not. Since it is `true`, the function returns `"It was true"`. When we call `test` with a value of `false`, `myCondition` is *not* `true` and the statement in the curly braces is not executed and the function returns `"It was false"`.
|
||||
`test(true)` devuelve la cadena `It was true` y `test(false)` devuelve la cadena `It was false`.
|
||||
|
||||
Cuando `test` es llamada con un valor de `true`, la sentencia `if` evalúa `myCondition` (mi condición) para ver si es `true` o no. Puesto que es `true`, la función devuelve `It was true`. Cuando llamamos a `test` con un valor de `false`, `myCondition` *no* es `true`, la sentencia dentro de las llaves no se ejecuta y la función devuelve `It was false`.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Create an `if` statement inside the function to return `"Yes, that was true"` if the parameter `wasThatTrue` is `true` and return `"No, that was false"` otherwise.
|
||||
Crea una sentencia `if` dentro de la función que devuelva `Yes, that was true` si el parámetro `wasThatTrue` es `true` y devuelva `No, that was false` en caso contrario.
|
||||
|
||||
# --hints--
|
||||
|
||||
`trueOrFalse` should be a function
|
||||
`trueOrFalse` debe ser una función
|
||||
|
||||
```js
|
||||
assert(typeof trueOrFalse === 'function');
|
||||
```
|
||||
|
||||
`trueOrFalse(true)` should return a string
|
||||
`trueOrFalse(true)` debe devolver una cadena
|
||||
|
||||
```js
|
||||
assert(typeof trueOrFalse(true) === 'string');
|
||||
```
|
||||
|
||||
`trueOrFalse(false)` should return a string
|
||||
`trueOrFalse(false)` debe devolver una cadena
|
||||
|
||||
```js
|
||||
assert(typeof trueOrFalse(false) === 'string');
|
||||
```
|
||||
|
||||
`trueOrFalse(true)` should return "Yes, that was true"
|
||||
`trueOrFalse(true)` debe devolver la cadena `Yes, that was true`
|
||||
|
||||
```js
|
||||
assert(trueOrFalse(true) === 'Yes, that was true');
|
||||
```
|
||||
|
||||
`trueOrFalse(false)` should return "No, that was false"
|
||||
`trueOrFalse(false)` debe devolver la cadena `No, that was false`
|
||||
|
||||
```js
|
||||
assert(trueOrFalse(false) === 'No, that was false');
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d7b7e367417b2b2512b21
|
||||
title: Use Multiple Conditional (Ternary) Operators
|
||||
title: Usa múltiples operadores condicionales (ternarios)
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/cyWJBT4'
|
||||
forumTopicId: 301179
|
||||
@ -9,9 +9,9 @@ dashedName: use-multiple-conditional-ternary-operators
|
||||
|
||||
# --description--
|
||||
|
||||
In the previous challenge, you used a single conditional operator. You can also chain them together to check for multiple conditions.
|
||||
En el desafío anterior, usaste un único operador condicional. También puedes encadenarlos para comprobar múltiples condiciones.
|
||||
|
||||
The following function uses if, else if, and else statements to check multiple conditions:
|
||||
La siguiente función utiliza sentencias `if`, `else if`, y `else` para comprobar múltiples condiciones:
|
||||
|
||||
```js
|
||||
function findGreaterOrEqual(a, b) {
|
||||
@ -27,7 +27,7 @@ function findGreaterOrEqual(a, b) {
|
||||
}
|
||||
```
|
||||
|
||||
The above function can be re-written using multiple conditional operators:
|
||||
La función anterior puede ser reescrita utilizando múltiples operadores condicionales:
|
||||
|
||||
```js
|
||||
function findGreaterOrEqual(a, b) {
|
||||
@ -37,7 +37,7 @@ function findGreaterOrEqual(a, b) {
|
||||
}
|
||||
```
|
||||
|
||||
It is considered best practice to format multiple conditional operators such that each condition is on a separate line, as shown above. Using multiple conditional operators without proper indentation may make your code hard to read. For example:
|
||||
Se considera buena práctica dar formato a múltiples operadores condicionales de forma que cada condición esté en una línea separada, como se muestra arriba. Usar múltiples operadores condicionales sin una indentación adecuada puede hacer tu código difícil de leer. Por ejemplo:
|
||||
|
||||
```js
|
||||
function findGreaterOrEqual(a, b) {
|
||||
@ -47,29 +47,29 @@ function findGreaterOrEqual(a, b) {
|
||||
|
||||
# --instructions--
|
||||
|
||||
In the `checkSign` function, use multiple conditional operators - following the recommended format used in `findGreaterOrEqual` - to check if a number is positive, negative or zero. The function should return `"positive"`, `"negative"` or `"zero"`.
|
||||
En la función `checkSign`, usa múltiples operadores condicionales (siguiendo el formato recomendado usado en `findGreaterOrEqual`) para comprobar si un número es positivo, negativo o cero. La función debe devolver `positive`, `negative` o `zero`.
|
||||
|
||||
# --hints--
|
||||
|
||||
`checkSign` should use multiple conditional operators
|
||||
`checkSign` debe utilizar múltiples operadores condicionales
|
||||
|
||||
```js
|
||||
assert(/.+?\s*?\?\s*?.+?\s*?:\s*?.+?\s*?\?\s*?.+?\s*?:\s*?.+?/gi.test(code));
|
||||
```
|
||||
|
||||
`checkSign(10)` should return "positive". Note that capitalization matters
|
||||
`checkSign(10)` debe devolver la cadena `positive`. Ten en cuenta que la capitalización importa
|
||||
|
||||
```js
|
||||
assert(checkSign(10) === 'positive');
|
||||
```
|
||||
|
||||
`checkSign(-12)` should return "negative". Note that capitalization matters
|
||||
`checkSign(-12)` debe devolver la cadena `negative`. Ten en cuenta que la capitalización importa
|
||||
|
||||
```js
|
||||
assert(checkSign(-12) === 'negative');
|
||||
```
|
||||
|
||||
`checkSign(0)` should return "zero". Note that capitalization matters
|
||||
`checkSign(0)` debe devolver la cadena `zero`. Ten en cuenta que la capitalización importa
|
||||
|
||||
```js
|
||||
assert(checkSign(0) === 'zero');
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 5cd9a70215d3c4e65518328f
|
||||
title: Use Recursion to Create a Countdown
|
||||
title: Utiliza recursión para crear una cuenta regresiva
|
||||
challengeType: 1
|
||||
forumTopicId: 305925
|
||||
dashedName: use-recursion-to-create-a-countdown
|
||||
@ -8,11 +8,11 @@ dashedName: use-recursion-to-create-a-countdown
|
||||
|
||||
# --description--
|
||||
|
||||
In a [previous challenge](/learn/javascript-algorithms-and-data-structures/basic-javascript/replace-loops-using-recursion), you learned how to use recursion to replace a for loop. Now, let's look at a more complex function that returns an array of consecutive integers starting with `1` through the number passed to the function.
|
||||
En el [desafío anterior](/learn/javascript-algorithms-and-data-structures/basic-javascript/replace-loops-using-recursion), aprendiste como usar la recursión para reemplazar un bucle `for`. Ahora, echemos un vistazo a una función más compleja que devuelve un arreglo de enteros consecutivos empezando con `1` hasta el número pasado a la función.
|
||||
|
||||
As mentioned in the previous challenge, there will be a <dfn>base case</dfn>. The base case tells the recursive function when it no longer needs to call itself. It is a simple case where the return value is already known. There will also be a <dfn>recursive call</dfn> which executes the original function with different arguments. If the function is written correctly, eventually the base case will be reached.
|
||||
Como se menciona en el desafío anterior, habrá un <dfn>caso base</dfn>. El caso base le dice a la función recursiva cuando no necesita llamarse a sí misma. Es un caso simple donde el valor de retorno ya se conoce. También habrá una <dfn>llamada recursiva</dfn> la cual ejecuta la función original con argumentos diferentes. Si la función se escribe correctamente, eventualmente el caso base será alcanzado.
|
||||
|
||||
For example, say you want to write a recursive function that returns an array containing the numbers `1` through `n`. This function will need to accept an argument, `n`, representing the final number. Then it will need to call itself with progressively smaller values of `n` until it reaches `1`. You could write the function as follows:
|
||||
Por ejemplo, digamos que quieres escribir una función recursiva que devuelva un arreglo conteniendo los números `1` hasta `n`. Esta función necesitará aceptar un argumento, `n` que representa el número final. Entonces necesitará llamarse a sí misma con valores progresivamente más pequeños de `n` hasta que alcance `1`. Podrías escribir la función de la siguiente manera:
|
||||
|
||||
```javascript
|
||||
function countup(n) {
|
||||
@ -24,36 +24,38 @@ function countup(n) {
|
||||
return countArray;
|
||||
}
|
||||
}
|
||||
console.log(countup(5)); // [ 1, 2, 3, 4, 5 ]
|
||||
console.log(countup(5));
|
||||
```
|
||||
|
||||
At first, this seems counterintuitive since the value of `n` *decreases*, but the values in the final array are *increasing*. This happens because the push happens last, after the recursive call has returned. At the point where `n` is pushed into the array, `countup(n - 1)` has already been evaluated and returned `[1, 2, ..., n - 1]`.
|
||||
El valor `[1, 2, 3, 4, 5]` se mostrará en la consola.
|
||||
|
||||
Al principio, esto parece contraintuitivo ya que el valor de `n` *disminuye*, pero los valores en el arreglo final se están *incrementando*. Esto sucede porque la inserción ocurre al último, después de la llamada recursiva. En el punto donde `n` es empujado en el arreglo, `countup(n - 1)` ya ha sido evaluada y devuelto `[1, 2, ..., n - 1]`.
|
||||
|
||||
# --instructions--
|
||||
|
||||
We have defined a function called `countdown` with one parameter (`n`). The function should use recursion to return an array containing the integers `n` through `1` based on the `n` parameter. If the function is called with a number less than 1, the function should return an empty array. For example, calling this function with `n = 5` should return the array `[5, 4, 3, 2, 1]`. Your function must use recursion by calling itself and must not use loops of any kind.
|
||||
Hemos definido una función llamada `countdown` con un parámetro (`n`). La función debe usar recursión para devolver un arreglo conteniendo los `n` enteros hasta `1` basado en el parámetro `n`. Si la función es llamada con un número menor a 1, la función debe devolver un arreglo vacío. Por ejemplo, llamar esta función con `n = 5` debe devolver el arreglo `[5, 4, 3, 2, 1]`. Tu función debe usar recursión llamándose a sí misma y no debe usar bucles de ningún tipo.
|
||||
|
||||
# --hints--
|
||||
|
||||
`countdown(-1)` should return an empty array.
|
||||
`countdown(-1)` debe devolver un arreglo vacío.
|
||||
|
||||
```js
|
||||
assert.isEmpty(countdown(-1));
|
||||
```
|
||||
|
||||
`countdown(10)` should return `[10, 9, 8, 7, 6, 5, 4, 3, 2, 1]`
|
||||
`countdown(10)` debe devolver `[10, 9, 8, 7, 6, 5, 4, 3, 2, 1]`
|
||||
|
||||
```js
|
||||
assert.deepStrictEqual(countdown(10), [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]);
|
||||
```
|
||||
|
||||
`countdown(5)` should return `[5, 4, 3, 2, 1]`
|
||||
`countdown(5)` debe devolver `[5, 4, 3, 2, 1]`
|
||||
|
||||
```js
|
||||
assert.deepStrictEqual(countdown(5), [5, 4, 3, 2, 1]);
|
||||
```
|
||||
|
||||
Your code should not rely on any kind of loops (`for`, `while` or higher order functions such as `forEach`, `map`, `filter`, and `reduce`).
|
||||
Tu código no debe depender de ningún tipo de bucles (`for`, `while` o funciones de orden alto tales como `forEach`, `map`, `filter`, y `reduce`).
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -63,7 +65,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
You should use recursion to solve this problem.
|
||||
Debes usar recursión para resolver este problema.
|
||||
|
||||
```js
|
||||
assert(
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 5cc0bd7a49b71cb96132e54c
|
||||
title: Use Recursion to Create a Range of Numbers
|
||||
title: Usa recursión para crear un rango de números
|
||||
challengeType: 1
|
||||
forumTopicId: 301180
|
||||
dashedName: use-recursion-to-create-a-range-of-numbers
|
||||
@ -8,21 +8,21 @@ dashedName: use-recursion-to-create-a-range-of-numbers
|
||||
|
||||
# --description--
|
||||
|
||||
Continuing from the previous challenge, we provide you another opportunity to create a recursive function to solve a problem.
|
||||
Continuando con el desafío anterior, te ofrecemos otra oportunidad de crear una función recursiva para resolver un problema.
|
||||
|
||||
# --instructions--
|
||||
|
||||
We have defined a function named `rangeOfNumbers` with two parameters. The function should return an array of integers which begins with a number represented by the `startNum` parameter and ends with a number represented by the `endNum` parameter. The starting number will always be less than or equal to the ending number. Your function must use recursion by calling itself and not use loops of any kind. It should also work for cases where both `startNum` and `endNum` are the same.
|
||||
Hemos definido una función llamada `rangeOfNumbers` con dos parámetros. La función debe devolver un arreglo de enteros que comienza con el número representado por el parámetro `startNum` y termina con el número representado por el parámetro `endNum`. El número inicial será siempre menor o igual que el número final. Tu función debe utilizar recursión, llamándose a sí misma, y no utilizar bucles de ningún tipo. También debe funcionar en el caso que `startNum` y `endNum` sean iguales.
|
||||
|
||||
# --hints--
|
||||
|
||||
Your function should return an array.
|
||||
Tu función debe devolver un arreglo.
|
||||
|
||||
```js
|
||||
assert(Array.isArray(rangeOfNumbers(5, 10)));
|
||||
```
|
||||
|
||||
Your code should not use any loop syntax (`for` or `while` or higher order functions such as `forEach`, `map`, `filter`, or `reduce`).
|
||||
Tu código no debe utilizar bucles (`for`, `while` o funciones de orden superior como `forEach`, `map`, `filter`, o `reduce`).
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -32,7 +32,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
`rangeOfNumbers` should use recursion (call itself) to solve this challenge.
|
||||
`rangeOfNumbers` debe utilizar recursión (llamadas a sí mismo) para resolver este desafío.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -42,19 +42,19 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
`rangeOfNumbers(1, 5)` should return `[1, 2, 3, 4, 5]`.
|
||||
`rangeOfNumbers(1, 5)` debe devolver `[1, 2, 3, 4, 5]`.
|
||||
|
||||
```js
|
||||
assert.deepStrictEqual(rangeOfNumbers(1, 5), [1, 2, 3, 4, 5]);
|
||||
```
|
||||
|
||||
`rangeOfNumbers(6, 9)` should return `[6, 7, 8, 9]`.
|
||||
`rangeOfNumbers(6, 9)` debe devolver `[6, 7, 8, 9]`.
|
||||
|
||||
```js
|
||||
assert.deepStrictEqual(rangeOfNumbers(6, 9), [6, 7, 8, 9]);
|
||||
```
|
||||
|
||||
`rangeOfNumbers(4, 4)` should return `[4]`.
|
||||
`rangeOfNumbers(4, 4)` debe devolver `[4]`.
|
||||
|
||||
```js
|
||||
assert.deepStrictEqual(rangeOfNumbers(4, 4), [4]);
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d7b7e367417b2b2512b24
|
||||
title: Use the Conditional (Ternary) Operator
|
||||
title: Usa el operador condicional (ternario)
|
||||
challengeType: 1
|
||||
forumTopicId: 301181
|
||||
dashedName: use-the-conditional-ternary-operator
|
||||
@ -8,13 +8,11 @@ dashedName: use-the-conditional-ternary-operator
|
||||
|
||||
# --description--
|
||||
|
||||
The <dfn>conditional operator</dfn>, also called the <dfn>ternary operator</dfn>, can be used as a one line if-else expression.
|
||||
El <dfn>operador condicional</dfn>, también llamado el <dfn>operador ternario</dfn>, puede utilizarse como una expresión if-else de una sola línea.
|
||||
|
||||
The syntax is:
|
||||
La sintaxis es `a ? b : c`, donde `a` es la condición, `b` es el código a ejecutar cuando la condición devuelve `true`, y `c` es el código a ejecutar cuando la condición devuelve `false`.
|
||||
|
||||
`condition ? expression-if-true : expression-if-false;`
|
||||
|
||||
The following function uses an if-else statement to check a condition:
|
||||
La siguiente función utiliza una sentencia `if/else` para comprobar una condición:
|
||||
|
||||
```js
|
||||
function findGreater(a, b) {
|
||||
@ -27,7 +25,7 @@ function findGreater(a, b) {
|
||||
}
|
||||
```
|
||||
|
||||
This can be re-written using the `conditional operator`:
|
||||
Esto puede reescribirse usando el operador condicional:
|
||||
|
||||
```js
|
||||
function findGreater(a, b) {
|
||||
@ -37,29 +35,29 @@ function findGreater(a, b) {
|
||||
|
||||
# --instructions--
|
||||
|
||||
Use the `conditional operator` in the `checkEqual` function to check if two numbers are equal or not. The function should return either "Equal" or "Not Equal".
|
||||
Utiliza el operador condicional en la función `checkEqual` para comprobar si dos números son iguales o no. La función debe devolver la cadena `Equal` o la cadena `Not Equal`.
|
||||
|
||||
# --hints--
|
||||
|
||||
`checkEqual` should use the `conditional operator`
|
||||
`checkEqual` debe usar el operador condicional
|
||||
|
||||
```js
|
||||
assert(/.+?\s*?\?\s*?.+?\s*?:\s*?.+?/.test(code));
|
||||
```
|
||||
|
||||
`checkEqual(1, 2)` should return "Not Equal"
|
||||
`checkEqual(1, 2)` debe devolver la cadena `Not Equal`
|
||||
|
||||
```js
|
||||
assert(checkEqual(1, 2) === 'Not Equal');
|
||||
```
|
||||
|
||||
`checkEqual(1, 1)` should return "Equal"
|
||||
`checkEqual(1, 1)` debe devolver la cadena `Equal`
|
||||
|
||||
```js
|
||||
assert(checkEqual(1, 1) === 'Equal');
|
||||
```
|
||||
|
||||
`checkEqual(1, -1)` should return "Not Equal"
|
||||
`checkEqual(1, -1)` debe devolver la cadena `Not Equal`
|
||||
|
||||
```js
|
||||
assert(checkEqual(1, -1) === 'Not Equal');
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d7b7e367417b2b2512b22
|
||||
title: Use the parseInt Function with a Radix
|
||||
title: Utiliza la función "parseInt" con Radix (Base)
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/c6K4Kh3'
|
||||
forumTopicId: 301182
|
||||
@ -9,49 +9,49 @@ dashedName: use-the-parseint-function-with-a-radix
|
||||
|
||||
# --description--
|
||||
|
||||
The `parseInt()` function parses a string and returns an integer. It takes a second argument for the radix, which specifies the base of the number in the string. The radix can be an integer between 2 and 36.
|
||||
La función `parseInt()` analiza una cadena y devuelve un entero. Recibe un segundo argumento para la base (radix), que especifica la base del número representado en la cadena. La base (radix) puede ser un número entero entre 2 y 36.
|
||||
|
||||
The function call looks like:
|
||||
La llamada a la función se realiza de la siguiente manera:
|
||||
|
||||
`parseInt(string, radix);`
|
||||
|
||||
And here's an example:
|
||||
A continuación, te presentamos un ejemplo:
|
||||
|
||||
`var a = parseInt("11", 2);`
|
||||
|
||||
The radix variable says that "11" is in the binary system, or base 2. This example converts the string "11" to an integer 3.
|
||||
La variable radix indica que `11` está en el sistema binario, o base 2. Este ejemplo convierte la cadena `11` a un entero `3`.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Use `parseInt()` in the `convertToInteger` function so it converts a binary number to an integer and returns it.
|
||||
Utiliza `parseInt()` dentro de la función `convertToInteger` para convertir un número binario en un número entero, y devuélvelo.
|
||||
|
||||
# --hints--
|
||||
|
||||
`convertToInteger` should use the `parseInt()` function
|
||||
`convertToInteger` debe utilizar la función `parseInt()`
|
||||
|
||||
```js
|
||||
assert(/parseInt/g.test(code));
|
||||
```
|
||||
|
||||
`convertToInteger("10011")` should return a number
|
||||
`convertToInteger("10011")` debe devolver un número
|
||||
|
||||
```js
|
||||
assert(typeof convertToInteger('10011') === 'number');
|
||||
```
|
||||
|
||||
`convertToInteger("10011")` should return 19
|
||||
`convertToInteger("10011")` debe devolver 19
|
||||
|
||||
```js
|
||||
assert(convertToInteger('10011') === 19);
|
||||
```
|
||||
|
||||
`convertToInteger("111001")` should return 57
|
||||
`convertToInteger("111001")` debe devolver 57
|
||||
|
||||
```js
|
||||
assert(convertToInteger('111001') === 57);
|
||||
```
|
||||
|
||||
`convertToInteger("JamesBond")` should return NaN
|
||||
`convertToInteger("JamesBond")` debe devolver `NaN`
|
||||
|
||||
```js
|
||||
assert.isNaN(convertToInteger('JamesBond'));
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d7b7e367417b2b2512b23
|
||||
title: Use the parseInt Function
|
||||
title: Utiliza la función "parseInt"
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/cm83LSW'
|
||||
forumTopicId: 301183
|
||||
@ -9,43 +9,43 @@ dashedName: use-the-parseint-function
|
||||
|
||||
# --description--
|
||||
|
||||
The `parseInt()` function parses a string and returns an integer. Here's an example:
|
||||
La función `parseInt()` analiza una cadena y devuelve un entero. A continuación, te presentamos un ejemplo:
|
||||
|
||||
`var a = parseInt("007");`
|
||||
|
||||
The above function converts the string "007" to an integer 7. If the first character in the string can't be converted into a number, then it returns `NaN`.
|
||||
La función anterior convierte la cadena `007` al entero `7`. Si el primer carácter de la cadena no puede ser convertido en un número, entonces devuelve `NaN`.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Use `parseInt()` in the `convertToInteger` function so it converts the input string `str` into an integer, and returns it.
|
||||
Utiliza `parseInt()` en la función `convertToInteger` para convertir la cadena de entrada `str` a un número entero, y devuélvelo.
|
||||
|
||||
# --hints--
|
||||
|
||||
`convertToInteger` should use the `parseInt()` function
|
||||
`convertToInteger` debe utilizar la función `parseInt()`
|
||||
|
||||
```js
|
||||
assert(/parseInt/g.test(code));
|
||||
```
|
||||
|
||||
`convertToInteger("56")` should return a number
|
||||
`convertToInteger("56")` debe devolver un número
|
||||
|
||||
```js
|
||||
assert(typeof convertToInteger('56') === 'number');
|
||||
```
|
||||
|
||||
`convertToInteger("56")` should return 56
|
||||
`convertToInteger("56")` debe devolver 56
|
||||
|
||||
```js
|
||||
assert(convertToInteger('56') === 56);
|
||||
```
|
||||
|
||||
`convertToInteger("77")` should return 77
|
||||
`convertToInteger("77")` debe devolver 77
|
||||
|
||||
```js
|
||||
assert(convertToInteger('77') === 77);
|
||||
```
|
||||
|
||||
`convertToInteger("JamesBond")` should return NaN
|
||||
`convertToInteger("JamesBond")` debe devolver `NaN`
|
||||
|
||||
```js
|
||||
assert.isNaN(convertToInteger('JamesBond'));
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244ca
|
||||
title: Using Objects for Lookups
|
||||
title: Usa objetos para hacer búsquedas
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/cdBk8sM'
|
||||
forumTopicId: 18373
|
||||
@ -9,9 +9,9 @@ dashedName: using-objects-for-lookups
|
||||
|
||||
# --description--
|
||||
|
||||
Objects can be thought of as a key/value storage, like a dictionary. If you have tabular data, you can use an object to "lookup" values rather than a `switch` statement or an `if/else` chain. This is most useful when you know that your input data is limited to a certain range.
|
||||
Los objetos pueden ser considerados como un almacenamiento clave/valor, como un diccionario. Si tienes datos tabulares, puedes utilizar un objeto para hacer una búsqueda de valores en lugar de una declaración `switch` o encadenar `if/else`. Esto es de mucha utilidad cuando se sabe que los datos de entrada están limitados a un cierto rango.
|
||||
|
||||
Here is an example of a simple reverse alphabet lookup:
|
||||
Aquí hay un ejemplo de una simple búsqueda de alfabeto inverso:
|
||||
|
||||
```js
|
||||
var alpha = {
|
||||
@ -24,68 +24,70 @@ var alpha = {
|
||||
25:"B",
|
||||
26:"A"
|
||||
};
|
||||
alpha[2]; // "Y"
|
||||
alpha[24]; // "C"
|
||||
alpha[2];
|
||||
alpha[24];
|
||||
|
||||
var value = 2;
|
||||
alpha[value]; // "Y"
|
||||
alpha[value];
|
||||
```
|
||||
|
||||
`alpha[2]` es la cadena `Y`, `alpha[24]` es la cadena `C`, y `alpha[value]` es la cadena `Y`.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Convert the switch statement into an object called `lookup`. Use it to look up `val` and assign the associated string to the `result` variable.
|
||||
Convierte la declaración switch en un objeto llamado `lookup`. Úsalo para buscar `val` y asignar la cadena asociada a la variable `result`.
|
||||
|
||||
# --hints--
|
||||
|
||||
`phoneticLookup("alpha")` should equal `"Adams"`
|
||||
`phoneticLookup("alpha")` debe ser igual a la cadena `Adams`
|
||||
|
||||
```js
|
||||
assert(phoneticLookup('alpha') === 'Adams');
|
||||
```
|
||||
|
||||
`phoneticLookup("bravo")` should equal `"Boston"`
|
||||
`phoneticLookup("bravo")` debe ser igual a la cadena `Boston`
|
||||
|
||||
```js
|
||||
assert(phoneticLookup('bravo') === 'Boston');
|
||||
```
|
||||
|
||||
`phoneticLookup("charlie")` should equal `"Chicago"`
|
||||
`phoneticLookup("charlie")` debe ser igual a la cadena `Chicago`
|
||||
|
||||
```js
|
||||
assert(phoneticLookup('charlie') === 'Chicago');
|
||||
```
|
||||
|
||||
`phoneticLookup("delta")` should equal `"Denver"`
|
||||
`phoneticLookup("delta")` debe ser igual a la cadena `Denver`
|
||||
|
||||
```js
|
||||
assert(phoneticLookup('delta') === 'Denver');
|
||||
```
|
||||
|
||||
`phoneticLookup("echo")` should equal `"Easy"`
|
||||
`phoneticLookup("echo")` debe ser igual a la cadena `Easy`
|
||||
|
||||
```js
|
||||
assert(phoneticLookup('echo') === 'Easy');
|
||||
```
|
||||
|
||||
`phoneticLookup("foxtrot")` should equal `"Frank"`
|
||||
`phoneticLookup("foxtrot")` debe ser igual a la cadena `Frank`
|
||||
|
||||
```js
|
||||
assert(phoneticLookup('foxtrot') === 'Frank');
|
||||
```
|
||||
|
||||
`phoneticLookup("")` should equal `undefined`
|
||||
`phoneticLookup("")` debe ser igual a `undefined`
|
||||
|
||||
```js
|
||||
assert(typeof phoneticLookup('') === 'undefined');
|
||||
```
|
||||
|
||||
You should not modify the `return` statement
|
||||
No debes modificar la sentencia `return`
|
||||
|
||||
```js
|
||||
assert(code.match(/return\sresult;/));
|
||||
```
|
||||
|
||||
You should not use `case`, `switch`, or `if` statements
|
||||
No debes usar sentencias `case`, `switch`o `if`
|
||||
|
||||
```js
|
||||
assert(
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 56bbb991ad1ed5201cd392cf
|
||||
title: Write Reusable JavaScript with Functions
|
||||
title: Escribe JavaScript reutilizable utilizando funciones
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/cL6dqfy'
|
||||
forumTopicId: 18378
|
||||
@ -9,9 +9,9 @@ dashedName: write-reusable-javascript-with-functions
|
||||
|
||||
# --description--
|
||||
|
||||
In JavaScript, we can divide up our code into reusable parts called <dfn>functions</dfn>.
|
||||
En JavaScript, podemos dividir nuestro código en partes reutilizables llamadas <dfn>funciones</dfn>.
|
||||
|
||||
Here's an example of a function:
|
||||
Este es un ejemplo de una función:
|
||||
|
||||
```js
|
||||
function functionName() {
|
||||
@ -19,27 +19,27 @@ function functionName() {
|
||||
}
|
||||
```
|
||||
|
||||
You can call or <dfn>invoke</dfn> this function by using its name followed by parentheses, like this: `functionName();` Each time the function is called it will print out the message `"Hello World"` on the dev console. All of the code between the curly braces will be executed every time the function is called.
|
||||
Puedes llamar o <dfn>invocar</dfn> esta función usando su nombre seguido por paréntesis, así: `functionName();` Cada vez que se llame la función se imprimirá el mensaje `Hello World` en la consola de desarrollo. Todo el código entre las llaves se ejecutará cada vez que se llame la función.
|
||||
|
||||
# --instructions--
|
||||
|
||||
<ol><li>Create a function called <code>reusableFunction</code> which prints <code>"Hi World"</code> to the dev console.</li><li>Call the function.</li></ol>
|
||||
<ol><li>Crea una función llamada <code>reusableFunction</code> que imprima <code>"Hi World"</code> en la consola de desarrollo.</li><li>Llama a la función.</li></ol>
|
||||
|
||||
# --hints--
|
||||
|
||||
`reusableFunction` should be a function.
|
||||
`reusableFunction` debe ser una función.
|
||||
|
||||
```js
|
||||
assert(typeof reusableFunction === 'function');
|
||||
```
|
||||
|
||||
`reusableFunction` should output "Hi World" to the dev console.
|
||||
`reusableFunction` debe mostrar la cadena `Hi World` en la consola.
|
||||
|
||||
```js
|
||||
assert(hiWorldWasLogged);
|
||||
```
|
||||
|
||||
You should call `reusableFunction` after you define it.
|
||||
Debes llamar `reusableFunction` después de definirla.
|
||||
|
||||
```js
|
||||
assert(/^\s*reusableFunction\(\)\s*/m.test(code));
|
||||
@ -87,7 +87,9 @@ if (typeof reusableFunction !== "function") {
|
||||
```
|
||||
|
||||
## --seed-contents--
|
||||
|
||||
```js
|
||||
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
Reference in New Issue
Block a user