chore(i18n,learn): processed translations (#41424)
* chore(i8n,learn): processed translations * Update curriculum/challenges/chinese/01-responsive-web-design/applied-visual-design/use-the-u-tag-to-underline-text.md Co-authored-by: Randell Dawson <5313213+RandellDawson@users.noreply.github.com> Co-authored-by: Crowdin Bot <support+bot@crowdin.com> Co-authored-by: Nicholas Carrigan (he/him) <nhcarrigan@gmail.com> Co-authored-by: Randell Dawson <5313213+RandellDawson@users.noreply.github.com>
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 56bbb991ad1ed5201cd392d2
|
||||
title: Add New Properties to a JavaScript Object
|
||||
title: Añade nuevas propiedades a un objeto de JavaScript
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/cQe38UD'
|
||||
forumTopicId: 301169
|
||||
@ -9,19 +9,19 @@ dashedName: add-new-properties-to-a-javascript-object
|
||||
|
||||
# --description--
|
||||
|
||||
You can add new properties to existing JavaScript objects the same way you would modify them.
|
||||
Puedes añadir nuevas propiedades a los objetos de JavaScript existentes de la misma manera que los modificarías.
|
||||
|
||||
Here's how we would add a `"bark"` property to `ourDog`:
|
||||
Así es como podríamos agregar una propiedad `bark` a nuestro objeto `ourDog`:
|
||||
|
||||
`ourDog.bark = "bow-wow";`
|
||||
|
||||
or
|
||||
o
|
||||
|
||||
`ourDog["bark"] = "bow-wow";`
|
||||
|
||||
Now when we evaluate `ourDog.bark`, we'll get his bark, "bow-wow".
|
||||
Ahora cuando evaluemos `ourDog.bark`, obtendremos su ladrido, `bow-wow`.
|
||||
|
||||
Example:
|
||||
Ejemplo:
|
||||
|
||||
```js
|
||||
var ourDog = {
|
||||
@ -36,17 +36,17 @@ ourDog.bark = "bow-wow";
|
||||
|
||||
# --instructions--
|
||||
|
||||
Add a `"bark"` property to `myDog` and set it to a dog sound, such as "woof". You may use either dot or bracket notation.
|
||||
Añade una propiedad `bark` a `myDog` y establécela a un sonido de perro, como "guau". Puedes usar tanto la notación de puntos como la notación de corchetes.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should add the property `"bark"` to `myDog`.
|
||||
Debes agregar la propiedad `bark` a `myDog`.
|
||||
|
||||
```js
|
||||
assert(myDog.bark !== undefined);
|
||||
```
|
||||
|
||||
You should not add `"bark"` to the setup section.
|
||||
No debes agregar `bark` a la sección de configuración (setup).
|
||||
|
||||
```js
|
||||
assert(!/bark[^\n]:/.test(code));
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: cf1111c1c11feddfaeb3bdef
|
||||
title: Add Two Numbers with JavaScript
|
||||
title: Suma dos números con JavaScript
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/cM2KBAG'
|
||||
forumTopicId: 16650
|
||||
@ -9,31 +9,33 @@ dashedName: add-two-numbers-with-javascript
|
||||
|
||||
# --description--
|
||||
|
||||
`Number` is a data type in JavaScript which represents numeric data.
|
||||
`Number` (número) es un tipo de datos en JavaScript que representa datos numéricos.
|
||||
|
||||
Now let's try to add two numbers using JavaScript.
|
||||
Ahora intentemos sumar dos números usando JavaScript.
|
||||
|
||||
JavaScript uses the `+` symbol as an addition operator when placed between two numbers.
|
||||
JavaScript utiliza el símbolo `+` como un operador de adición cuando se coloca entre dos números.
|
||||
|
||||
**Example:**
|
||||
**Ejemplo:**
|
||||
|
||||
```js
|
||||
myVar = 5 + 10; // assigned 15
|
||||
myVar = 5 + 10;
|
||||
```
|
||||
|
||||
`myVar` ahora tiene el valor `15`.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Change the `0` so that sum will equal `20`.
|
||||
Cambia el `0` para que la suma sea igual a `20`.
|
||||
|
||||
# --hints--
|
||||
|
||||
`sum` should equal `20`.
|
||||
`sum` debe ser igual a `20`.
|
||||
|
||||
```js
|
||||
assert(sum === 20);
|
||||
```
|
||||
|
||||
You should use the `+` operator.
|
||||
Debes usar el operador `+`.
|
||||
|
||||
```js
|
||||
assert(/\+/.test(code));
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244de
|
||||
title: Adding a Default Option in Switch Statements
|
||||
title: Agrega una opción predeterminada en las declaraciones switch
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/c3JvVfg'
|
||||
forumTopicId: 16653
|
||||
@ -9,9 +9,9 @@ dashedName: adding-a-default-option-in-switch-statements
|
||||
|
||||
# --description--
|
||||
|
||||
In a `switch` statement you may not be able to specify all possible values as `case` statements. Instead, you can add the `default` statement which will be executed if no matching `case` statements are found. Think of it like the final `else` statement in an `if/else` chain.
|
||||
En una declaración `switch` puede que no seas capaz de especificar todos los valores posibles como declaraciones de `case` (caso). En su lugar, se puede añadir la declaración `default`, la cual se ejecutará si no se encuentran declaraciones `case`. Piensa en ella como la última sentencia `else` en una cadena `if/else`.
|
||||
|
||||
A `default` statement should be the last case.
|
||||
Una declaración `default` debe ser el último caso.
|
||||
|
||||
```js
|
||||
switch (num) {
|
||||
@ -30,57 +30,57 @@ switch (num) {
|
||||
|
||||
# --instructions--
|
||||
|
||||
Write a switch statement to set `answer` for the following conditions:
|
||||
`"a"` - "apple"
|
||||
`"b"` - "bird"
|
||||
`"c"` - "cat"
|
||||
`default` - "stuff"
|
||||
Escribe una declaración switch para establecer `answer` con las siguientes condiciones:
|
||||
`a` - `apple`
|
||||
`b` - `bird`
|
||||
`c` - `cat`
|
||||
`default` - `stuff`
|
||||
|
||||
# --hints--
|
||||
|
||||
`switchOfStuff("a")` should have a value of "apple"
|
||||
`switchOfStuff("a")` debe devolver la cadena `apple`
|
||||
|
||||
```js
|
||||
assert(switchOfStuff('a') === 'apple');
|
||||
```
|
||||
|
||||
`switchOfStuff("b")` should have a value of "bird"
|
||||
`switchOfStuff("b")` debe devolver la cadena `bird`
|
||||
|
||||
```js
|
||||
assert(switchOfStuff('b') === 'bird');
|
||||
```
|
||||
|
||||
`switchOfStuff("c")` should have a value of "cat"
|
||||
`switchOfStuff("c")` debe devolver la cadena `cat`
|
||||
|
||||
```js
|
||||
assert(switchOfStuff('c') === 'cat');
|
||||
```
|
||||
|
||||
`switchOfStuff("d")` should have a value of "stuff"
|
||||
`switchOfStuff("d")` debe devolver la cadena `stuff`
|
||||
|
||||
```js
|
||||
assert(switchOfStuff('d') === 'stuff');
|
||||
```
|
||||
|
||||
`switchOfStuff(4)` should have a value of "stuff"
|
||||
`switchOfStuff(4)` debe devolver la cadena `stuff`
|
||||
|
||||
```js
|
||||
assert(switchOfStuff(4) === 'stuff');
|
||||
```
|
||||
|
||||
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 use a `default` statement
|
||||
Debes utilizar una declaración `default`
|
||||
|
||||
```js
|
||||
assert(switchOfStuff('string-to-trigger-default-case') === 'stuff');
|
||||
```
|
||||
|
||||
You should have at least 3 `break` statements
|
||||
Debes tener al menos 3 declaraciones de ruptura (`break`)
|
||||
|
||||
```js
|
||||
assert(code.match(/break/g).length > 2);
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244ed
|
||||
title: Appending Variables to Strings
|
||||
title: Agrega variables a cadenas
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/cbQmZfa'
|
||||
forumTopicId: 16656
|
||||
@ -9,30 +9,31 @@ dashedName: appending-variables-to-strings
|
||||
|
||||
# --description--
|
||||
|
||||
Just as we can build a string over multiple lines out of string <dfn>literals</dfn>, we can also append variables to a string using the plus equals (`+=`) operator.
|
||||
Al igual que podemos construir una cadena sobre múltiples líneas a partir de las cadenas <dfn>literales</dfn>, también podemos añadir variables a una cadena usando el operador "más igual" (`+=`).
|
||||
|
||||
Example:
|
||||
Ejemplo:
|
||||
|
||||
```js
|
||||
var anAdjective = "awesome!";
|
||||
var ourStr = "freeCodeCamp is ";
|
||||
ourStr += anAdjective;
|
||||
// ourStr is now "freeCodeCamp is awesome!"
|
||||
```
|
||||
|
||||
`ourStr` tendrá el valor de `freeCodeCamp is awesome!`.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Set `someAdjective` to a string of at least 3 characters and append it to `myStr` using the `+=` operator.
|
||||
Establece `someAdjective` a una cadena de al menos 3 caracteres y añádelo a `myStr` usando el operador `+=`.
|
||||
|
||||
# --hints--
|
||||
|
||||
`someAdjective` should be set to a string at least 3 characters long.
|
||||
`someAdjective` debe ser establecido a una cadena de al menos 3 caracteres.
|
||||
|
||||
```js
|
||||
assert(typeof someAdjective !== 'undefined' && someAdjective.length > 2);
|
||||
```
|
||||
|
||||
You should append `someAdjective` to `myStr` using the `+=` operator.
|
||||
Debes añadir `someAdjective` a `myStr` usando el operador `+=`.
|
||||
|
||||
```js
|
||||
assert(code.match(/myStr\s*\+=\s*someAdjective\s*/).length > 0);
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 5ee127a03c3b35dd45426493
|
||||
title: Assigning the Value of One Variable to Another
|
||||
title: Asigna el valor de una variable a otra variable
|
||||
challengeType: 1
|
||||
videoUrl: ''
|
||||
forumTopicId: 418265
|
||||
@ -9,7 +9,7 @@ dashedName: assigning-the-value-of-one-variable-to-another
|
||||
|
||||
# --description--
|
||||
|
||||
After a value is assigned to a variable using the <dfn>assignment</dfn> operator, you can assign the value of that variable to another variable using the <dfn>assignment</dfn> operator.
|
||||
Después de asignar un valor a una variable usando el operador de <dfn>asignación</dfn>, puedes asignar el valor de esa variable a otra variable usando el mismo operador de <dfn>asignación</dfn>.
|
||||
|
||||
```js
|
||||
var myVar;
|
||||
@ -18,27 +18,27 @@ var myNum;
|
||||
myNum = myVar;
|
||||
```
|
||||
|
||||
The above declares a `myVar` variable with no value, then assigns it the value `5`. Next, a variable named `myNum` is declared with no value. Then, the contents of `myVar` (which is `5`) is assigned to the variable `myNum`. Now, `myNum` also has the value of `5`.
|
||||
Lo anterior declara una variable `myVar` sin valor, y luego le asigna el valor `5`. A continuación, una variable llamada `myNum` es declarada, tambien sin valor. Luego, el contenido de `myVar` (que es `5`) se asigna a la variable `myNum`. Ahora, `myNum` también tiene el valor de `5`.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Assign the contents of `a` to variable `b`.
|
||||
Asigna el contenido de `a` a la variable `b`.
|
||||
|
||||
# --hints--
|
||||
|
||||
You should not change code above the specified comment.
|
||||
No debes cambiar el código por encima del comentario especificado.
|
||||
|
||||
```js
|
||||
assert(/var a;/.test(code) && /a = 7;/.test(code) && /var b;/.test(code));
|
||||
```
|
||||
|
||||
`b` should have a value of 7.
|
||||
`b` debe tener un valor de `7`.
|
||||
|
||||
```js
|
||||
assert(typeof b === 'number' && b === 7);
|
||||
```
|
||||
|
||||
`a` should be assigned to `b` with `=`.
|
||||
`a` debe ser asignado a `b` utilizando `=`.
|
||||
|
||||
```js
|
||||
assert(/b\s*=\s*a\s*/g.test(code));
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244c3
|
||||
title: Assignment with a Returned Value
|
||||
title: Asignación con un valor devuelto
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/ce2pEtB'
|
||||
forumTopicId: 16658
|
||||
@ -9,27 +9,27 @@ dashedName: assignment-with-a-returned-value
|
||||
|
||||
# --description--
|
||||
|
||||
If you'll recall from our discussion of [Storing Values with the Assignment Operator](/learn/javascript-algorithms-and-data-structures/basic-javascript/storing-values-with-the-assignment-operator), everything to the right of the equal sign is resolved before the value is assigned. This means we can take the return value of a function and assign it to a variable.
|
||||
Si recuerdas de nuestra discusión sobre [almacenar valores con el operador de asignación](/learn/javascript-algorithms-and-data-structures/basic-javascript/storing-values-with-the-assignment-operator), todo a la derecha del signo de igualdad se resuelve antes de asignar el valor. Esto significa que podemos tomar el valor devuelto de una función y asignarlo a una variable.
|
||||
|
||||
Assume we have pre-defined a function `sum` which adds two numbers together, then:
|
||||
Supongamos que hemos predefinido una función `sum` que suma dos números juntos, entonces:
|
||||
|
||||
`ourSum = sum(5, 12);`
|
||||
|
||||
will call `sum` function, which returns a value of `17` and assigns it to `ourSum` variable.
|
||||
llamará a la función `sum`, la cual devuelve un valor de `17` y lo asigna a la variable `ourSum`.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Call the `processArg` function with an argument of `7` and assign its return value to the variable `processed`.
|
||||
Llama a la función `processArg` con un argumento de `7` y asigna su valor devuelto a la variable `processed`.
|
||||
|
||||
# --hints--
|
||||
|
||||
`processed` should have a value of `2`
|
||||
`processed` debe tener un valor de `2`
|
||||
|
||||
```js
|
||||
assert(processed === 2);
|
||||
```
|
||||
|
||||
You should assign `processArg` to `processed`
|
||||
Debes asignar `processArg` a `processed`
|
||||
|
||||
```js
|
||||
assert(/processed\s*=\s*processArg\(\s*7\s*\)/.test(code));
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 56bbb991ad1ed5201cd392d0
|
||||
title: Build JavaScript Objects
|
||||
title: Construye objetos en JavaScript
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/cWGkbtd'
|
||||
forumTopicId: 16769
|
||||
@ -9,13 +9,13 @@ dashedName: build-javascript-objects
|
||||
|
||||
# --description--
|
||||
|
||||
You may have heard the term `object` before.
|
||||
Es posible que hayas escuchado el término objeto (`object`) antes.
|
||||
|
||||
Objects are similar to `arrays`, except that instead of using indexes to access and modify their data, you access the data in objects through what are called `properties`.
|
||||
Los objetos son similares a los arreglos (`arrays`), excepto que en lugar de usar índices para acceder y modificar sus datos, accedes a los datos en objetos a través de propiedades (`properties`).
|
||||
|
||||
Objects are useful for storing data in a structured way, and can represent real world objects, like a cat.
|
||||
Los objetos son útiles para almacenar datos de forma estructurada y pueden representar objetos del mundo real, como un gato.
|
||||
|
||||
Here's a sample cat object:
|
||||
Por ejemplo, aquí hay un objeto de gato:
|
||||
|
||||
```js
|
||||
var cat = {
|
||||
@ -26,7 +26,7 @@ var cat = {
|
||||
};
|
||||
```
|
||||
|
||||
In this example, all the properties are stored as strings, such as - `"name"`, `"legs"`, and `"tails"`. However, you can also use numbers as properties. You can even omit the quotes for single-word string properties, as follows:
|
||||
En este ejemplo, todas las propiedades se almacenan como cadenas, tales como: `name`, `legs` y `tails`. Sin embargo, también puedes utilizar números como propiedades. Incluso puedes omitir las comillas para las propiedades de cadenas de una sola palabra, de la siguiente manera:
|
||||
|
||||
```js
|
||||
var anotherObject = {
|
||||
@ -36,17 +36,17 @@ var anotherObject = {
|
||||
};
|
||||
```
|
||||
|
||||
However, if your object has any non-string properties, JavaScript will automatically typecast them as strings.
|
||||
Sin embargo, si tu objeto tiene propiedades que no son cadenas, JavaScript las convertirá automáticamente en cadenas.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Make an object that represents a dog called `myDog` which contains the properties `"name"` (a string), `"legs"`, `"tails"` and `"friends"`.
|
||||
Crea un objeto que represente a un perro llamado `myDog` que contenga las propiedades `name` (una cadena), `legs`, `tails` y `friends`.
|
||||
|
||||
You can set these object properties to whatever values you want, as long as `"name"` is a string, `"legs"` and `"tails"` are numbers, and `"friends"` is an array.
|
||||
Puedes establecer estas propiedades del objeto a los valores que quieras, siempre y cuando `name` sea una cadena, `legs` y `tails` sean números, y `friends` sea un arreglo.
|
||||
|
||||
# --hints--
|
||||
|
||||
`myDog` should contain the property `name` and it should be a `string`.
|
||||
`myDog` debe contener la propiedad `name` y debe ser una cadena (`string`).
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -64,7 +64,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
`myDog` should contain the property `legs` and it should be a `number`.
|
||||
`myDog` debe contener la propiedad `legs` y debe ser un número (`number`).
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -82,7 +82,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
`myDog` should contain the property `tails` and it should be a `number`.
|
||||
`myDog` debe contener la propiedad `tails` y debe ser un número (`number`).
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -100,7 +100,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
`myDog` should contain the property `friends` and it should be an `array`.
|
||||
`myDog` debe contener la propiedad `friends` y debe ser un arreglo (`array`).
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -118,7 +118,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
`myDog` should only contain all the given properties.
|
||||
`myDog` sólo debe contener todas las propiedades dadas.
|
||||
|
||||
```js
|
||||
assert(
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244dc
|
||||
title: Chaining If Else Statements
|
||||
title: Encadena sentencias if else
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/caeJgsw'
|
||||
forumTopicId: 16772
|
||||
@ -9,7 +9,7 @@ dashedName: chaining-if-else-statements
|
||||
|
||||
# --description--
|
||||
|
||||
`if/else` statements can be chained together for complex logic. Here is <dfn>pseudocode</dfn> of multiple chained `if` / `else if` statements:
|
||||
Las sentencias `if/else` pueden ser encadenadas para crear una lógica compleja. Aquí hay <dfn>pseudocódigo</dfn> de múltiples declaraciones `if` / `else if` encadenadas:
|
||||
|
||||
```js
|
||||
if (condition1) {
|
||||
@ -26,89 +26,89 @@ if (condition1) {
|
||||
|
||||
# --instructions--
|
||||
|
||||
Write chained `if`/`else if` statements to fulfill the following conditions:
|
||||
Escribe sentencias `if` / `else if` encadenadas para cumplir con las siguientes condiciones:
|
||||
|
||||
`num < 5` - return "Tiny"
|
||||
`num < 10` - return "Small"
|
||||
`num < 15` - return "Medium"
|
||||
`num < 20` - return "Large"
|
||||
`num >= 20` - return "Huge"
|
||||
`num < 5` - devuelve `Tiny`
|
||||
`num < 10` - devuelve `Small`
|
||||
`num < 15` - devuelve `Medium`
|
||||
`num < 20` - devuelve `Large`
|
||||
`num >= 20` - devuelve `Huge`
|
||||
|
||||
# --hints--
|
||||
|
||||
You should have at least four `else` statements
|
||||
Debes tener al menos cuatro sentencias `else`
|
||||
|
||||
```js
|
||||
assert(code.match(/else/g).length > 3);
|
||||
```
|
||||
|
||||
You should have at least four `if` statements
|
||||
Debes tener al menos cuatro sentencias `if`
|
||||
|
||||
```js
|
||||
assert(code.match(/if/g).length > 3);
|
||||
```
|
||||
|
||||
You should have at least one `return` statement
|
||||
Debes tener al menos una sentencia `return`
|
||||
|
||||
```js
|
||||
assert(code.match(/return/g).length >= 1);
|
||||
```
|
||||
|
||||
`testSize(0)` should return "Tiny"
|
||||
`testSize(0)` debe devolver la cadena `Tiny`
|
||||
|
||||
```js
|
||||
assert(testSize(0) === 'Tiny');
|
||||
```
|
||||
|
||||
`testSize(4)` should return "Tiny"
|
||||
`testSize(4)` debe devolver la cadena `Tiny`
|
||||
|
||||
```js
|
||||
assert(testSize(4) === 'Tiny');
|
||||
```
|
||||
|
||||
`testSize(5)` should return "Small"
|
||||
`testSize(5)`debe devolver la cadena `Small`
|
||||
|
||||
```js
|
||||
assert(testSize(5) === 'Small');
|
||||
```
|
||||
|
||||
`testSize(8)` should return "Small"
|
||||
`testSize(8)` debe devolver la cadena `Small`
|
||||
|
||||
```js
|
||||
assert(testSize(8) === 'Small');
|
||||
```
|
||||
|
||||
`testSize(10)` should return "Medium"
|
||||
`testSize(10)` debe devolver la cadena `Medium`
|
||||
|
||||
```js
|
||||
assert(testSize(10) === 'Medium');
|
||||
```
|
||||
|
||||
`testSize(14)` should return "Medium"
|
||||
`testSize(14)` debe devolver la cadena `Medium`
|
||||
|
||||
```js
|
||||
assert(testSize(14) === 'Medium');
|
||||
```
|
||||
|
||||
`testSize(15)` should return "Large"
|
||||
`testSize(15)` debe devolver la cadena `Large`
|
||||
|
||||
```js
|
||||
assert(testSize(15) === 'Large');
|
||||
```
|
||||
|
||||
`testSize(17)` should return "Large"
|
||||
`testSize(17)` debe devolver la cadena `Large`
|
||||
|
||||
```js
|
||||
assert(testSize(17) === 'Large');
|
||||
```
|
||||
|
||||
`testSize(20)` should return "Huge"
|
||||
`testSize(20)` debe devolver la cadena `Huge`
|
||||
|
||||
```js
|
||||
assert(testSize(20) === 'Huge');
|
||||
```
|
||||
|
||||
`testSize(25)` should return "Huge"
|
||||
`testSize(25)` debe devolver la cadena `Huge`
|
||||
|
||||
```js
|
||||
assert(testSize(25) === 'Huge');
|
||||
|
@ -13,21 +13,20 @@ Los comentarios son líneas de código que JavaScript ignorará intencionalmente
|
||||
|
||||
Hay dos maneras de escribir comentarios en JavaScript:
|
||||
|
||||
Usar `//` le dirá a JavaScript que ignore el resto del texto en la línea actual:
|
||||
Usar `//` le dirá a JavaScript que ignore el resto del texto en la línea actual. Este es un comentario en línea:
|
||||
|
||||
```js
|
||||
// This is an in-line comment.
|
||||
```
|
||||
|
||||
Puedes hacer un comentario multi-línea comenzando con `/*` y terminando con `*/`:
|
||||
Puedes hacer un comentario multilínea comenzando con `/*` y terminando con `*/`. Este es un comentario multilínea:
|
||||
|
||||
```js
|
||||
/* This is a
|
||||
multi-line comment */
|
||||
```
|
||||
|
||||
**Buena práctica**
|
||||
A medida que escribes código, deberías añadir comentarios regularmente para aclarar el funcionamiento de las partes de tu código. Un buen comentario puede ayudar a comunicar la intención de tu código, tanto para otros *como* para tu yo futuro.
|
||||
**Nota: ** A medida que programas, deberías añadir comentarios regularmente para aclarar el funcionamiento de las partes de tu código. Un buen comentario puede ayudar a comunicar la intención de tu código, tanto para otros *como* para tu yo futuro.
|
||||
|
||||
# --instructions--
|
||||
|
||||
@ -50,7 +49,9 @@ assert(code.match(/(\/\*)([^\/]{5,})(?=\*\/)/gm));
|
||||
# --seed--
|
||||
|
||||
## --seed-contents--
|
||||
|
||||
```js
|
||||
|
||||
```
|
||||
|
||||
# --solutions--
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244d0
|
||||
title: Comparison with the Equality Operator
|
||||
title: Comparación con el operador de igualdad
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/cKyVMAL'
|
||||
forumTopicId: 16784
|
||||
@ -9,9 +9,9 @@ dashedName: comparison-with-the-equality-operator
|
||||
|
||||
# --description--
|
||||
|
||||
There are many <dfn>comparison operators</dfn> in JavaScript. All of these operators return a boolean `true` or `false` value.
|
||||
Hay muchos <dfn>operadores de comparación</dfn> en JavaScript. Todos estos operadores devuelven un valor booleano `true` o `false`.
|
||||
|
||||
The most basic operator is the equality operator `==`. The equality operator compares two values and returns `true` if they're equivalent or `false` if they are not. Note that equality is different from assignment (`=`), which assigns the value on the right of the operator to a variable on the left.
|
||||
El operador más básico es el de igualdad `==`. El operador de igualdad compara dos valores y devuelve `true` si son equivalentes o `false` si no lo son. Ten en cuenta que una igualdad es diferente a una asignación (`=`), la cual asigna el valor a la derecha del operador a la variable de la izquierda.
|
||||
|
||||
```js
|
||||
function equalityTest(myVal) {
|
||||
@ -22,40 +22,42 @@ function equalityTest(myVal) {
|
||||
}
|
||||
```
|
||||
|
||||
If `myVal` is equal to `10`, the equality operator returns `true`, so the code in the curly braces will execute, and the function will return `"Equal"`. Otherwise, the function will return `"Not Equal"`. In order for JavaScript to compare two different <dfn>data types</dfn> (for example, `numbers` and `strings`), it must convert one type to another. This is known as "Type Coercion". Once it does, however, it can compare terms as follows:
|
||||
Si `myVal` es igual a `10`, el operador de igualdad devuelve `true`, así que el código dentro de los corchetes se ejecutará y la función devolverá `Equal`. De lo contrario, la función devolverá `Not Equal`. Para que JavaScript compare dos <dfn>tipos de datos</dfn> diferentes (por ejemplo, `numbers` y `strings`), tiene que convertir un tipo a otro. Esto se conoce como Coerción de Tipo. Sin embargo, una vez lo hace, puede comparar términos como se ve a continuación:
|
||||
|
||||
```js
|
||||
1 == 1 // true
|
||||
1 == 2 // false
|
||||
1 == '1' // true
|
||||
"3" == 3 // true
|
||||
1 == 1
|
||||
1 == 2
|
||||
1 == '1'
|
||||
"3" == 3
|
||||
```
|
||||
|
||||
En orden, estas expresiones se evaluarían como `true`, `false`, `true` y `true`.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Add the equality operator to the indicated line so that the function will return "Equal" when `val` is equivalent to `12`.
|
||||
Agrega el operador de igualdad a la línea indicada para que la función devuelva la cadena `Equal` cuando `val` sea equivalente a `12`.
|
||||
|
||||
# --hints--
|
||||
|
||||
`testEqual(10)` should return "Not Equal"
|
||||
`testEqual(10)` debe devolver la cadena `Not Equal`
|
||||
|
||||
```js
|
||||
assert(testEqual(10) === 'Not Equal');
|
||||
```
|
||||
|
||||
`testEqual(12)` should return "Equal"
|
||||
`testEqual(12)` debe devolver la cadena `Equal`
|
||||
|
||||
```js
|
||||
assert(testEqual(12) === 'Equal');
|
||||
```
|
||||
|
||||
`testEqual("12")` should return "Equal"
|
||||
`testEqual("12")` debe devolver la cadena `Equal`
|
||||
|
||||
```js
|
||||
assert(testEqual('12') === 'Equal');
|
||||
```
|
||||
|
||||
You should use the `==` operator
|
||||
Debes usar el operador `==`
|
||||
|
||||
```js
|
||||
assert(code.match(/==/g) && !code.match(/===/g));
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244d4
|
||||
title: Comparación con el operador Mayor que
|
||||
title: Comparación con el operador "mayor que"
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/cp6GbH4'
|
||||
forumTopicId: 16786
|
||||
@ -16,55 +16,57 @@ Como el operador de igualdad, el operador mayor que convertirá los tipos de dat
|
||||
**Ejemplos**
|
||||
|
||||
```js
|
||||
5 > 3 // true
|
||||
7 > '3' // true
|
||||
2 > 3 // false
|
||||
'1' > 9 // false
|
||||
5 > 3
|
||||
7 > '3'
|
||||
2 > 3
|
||||
'1' > 9
|
||||
```
|
||||
|
||||
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--
|
||||
|
||||
`testGreaterThan(0)` debe devolver "10 or Under"
|
||||
`testGreaterThan(0)` debe devolver la cadena `10 or Under`
|
||||
|
||||
```js
|
||||
assert(testGreaterThan(0) === '10 or Under');
|
||||
```
|
||||
|
||||
`testGreaterThan(10)` debe devolver "10 or Under"
|
||||
`testGreaterThan(10)` debe devolver la cadena `10 or Under`
|
||||
|
||||
```js
|
||||
assert(testGreaterThan(10) === '10 or Under');
|
||||
```
|
||||
|
||||
`testGreaterThan(11)` debe devolver "Over 10"
|
||||
`testGreaterThan(11)` debe devolver la cadena `Over 10`
|
||||
|
||||
```js
|
||||
assert(testGreaterThan(11) === 'Over 10');
|
||||
```
|
||||
|
||||
`testGreaterThan(99)` debe devolver "Over 10"
|
||||
`testGreaterThan(99)` debe devolver la cadena `Over 10`
|
||||
|
||||
```js
|
||||
assert(testGreaterThan(99) === 'Over 10');
|
||||
```
|
||||
|
||||
`testGreaterThan(100)` debe devolver "Over 10"
|
||||
`testGreaterThan(100)` debe devolver la cadena `Over 10`
|
||||
|
||||
```js
|
||||
assert(testGreaterThan(100) === 'Over 10');
|
||||
```
|
||||
|
||||
`testGreaterThan(101)` debe devolver "Over 100"
|
||||
`testGreaterThan(101)` debe devolver la cadena `Over 100`
|
||||
|
||||
```js
|
||||
assert(testGreaterThan(101) === 'Over 100');
|
||||
```
|
||||
|
||||
`testGreaterThan(150)` debe devolver"Over 100"
|
||||
`testGreaterThan(150)` debe devolver la cadena `Over 100`
|
||||
|
||||
```js
|
||||
assert(testGreaterThan(150) === 'Over 100');
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244b8
|
||||
title: Concatenating Strings with the Plus Equals Operator
|
||||
title: Concatena cadenas con el operador "más igual"
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/cbQmmC4'
|
||||
forumTopicId: 16803
|
||||
@ -9,32 +9,32 @@ dashedName: concatenating-strings-with-the-plus-equals-operator
|
||||
|
||||
# --description--
|
||||
|
||||
We can also use the `+=` operator to <dfn>concatenate</dfn> a string onto the end of an existing string variable. This can be very helpful to break a long string over several lines.
|
||||
También podemos utilizar el operador `+=` para <dfn>concatenar</dfn> una cadena al final de una variable de cadena existente. Esto puede ser muy útil para romper una cadena larga en varias líneas.
|
||||
|
||||
**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. ";
|
||||
ourStr += "I come second.";
|
||||
// ourStr is now "I come first. I come second."
|
||||
```
|
||||
|
||||
`ourStr` ahora tiene un valor de la cadena `I come first. I come second.`.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Build `myStr` over several lines by concatenating these two strings: `"This is the first sentence. "` and `"This is the second sentence."` using the `+=` operator. Use the `+=` operator similar to how it is shown in the editor. Start by assigning the first string to `myStr`, then add on the second string.
|
||||
Construye `myStr` en varias líneas concatenando estas dos cadenas: `This is the first sentence.` y `This is the second sentence.` usando el operador `+=`. Utiliza el operador `+=` de forma similar a como se muestra en el editor. Comienza asignando la primera cadena a `myStr`, luego añade la segunda cadena.
|
||||
|
||||
# --hints--
|
||||
|
||||
`myStr` should have a value of `This is the first sentence. This is the second sentence.`
|
||||
`myStr` debe tener una cadena con valor `This is the first sentence. This is the second sentence.`
|
||||
|
||||
```js
|
||||
assert(myStr === 'This is the first sentence. This is the second sentence.');
|
||||
```
|
||||
|
||||
You should use the `+=` operator to build `myStr`.
|
||||
Debes usar el operador `+=` para construir `myStr`.
|
||||
|
||||
```js
|
||||
assert(code.match(/myStr\s*\+=\s*(["']).*\1/g));
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: cf1111c1c12feddfaeb1bdef
|
||||
title: Generate Random Whole Numbers with JavaScript
|
||||
title: Genera números enteros aleatorios con JavaScript
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/cRn6bfr'
|
||||
forumTopicId: 18186
|
||||
@ -9,25 +9,25 @@ dashedName: generate-random-whole-numbers-with-javascript
|
||||
|
||||
# --description--
|
||||
|
||||
It's great that we can generate random decimal numbers, but it's even more useful if we use it to generate random whole numbers.
|
||||
Es genial que podamos generar números decimales aleatorios, pero es incluso más útil si lo usamos para generar números enteros aleatorios.
|
||||
|
||||
<ol><li>Use <code>Math.random()</code> to generate a random decimal.</li><li>Multiply that random decimal by <code>20</code>.</li><li>Use another function, <code>Math.floor()</code> to round the number down to its nearest whole number.</li></ol>
|
||||
<ol><li>Usa <code>Math.random()</code> para generar un decimal aleatorio.</li><li>Multiplica ese decimal aleatorio por <code>20</code>.</li><li>Utiliza otra función, <code>Math.floor()</code> para redondear el número hacia abajo a su número entero más cercano.</li></ol>
|
||||
|
||||
Remember that `Math.random()` can never quite return a `1` and, because we're rounding down, it's impossible to actually get `20`. This technique will give us a whole number between `0` and `19`.
|
||||
Recuerda que `Math.random()` nunca devolverá un `1` y porque estamos redondeando hacia abajo, es imposible obtener `20`. Esta técnica nos dará un número entero entre `0` y `19`.
|
||||
|
||||
Putting everything together, this is what our code looks like:
|
||||
Poniendo todo junto, así es como se ve nuestro código:
|
||||
|
||||
`Math.floor(Math.random() * 20);`
|
||||
|
||||
We are calling `Math.random()`, multiplying the result by 20, then passing the value to `Math.floor()` function to round the value down to the nearest whole number.
|
||||
Estamos llamando a `Math.random()`, multiplicando el resultado por 20 y pasando el valor a la función `Math.floor()` para redondear el valor hacia abajo al número entero más cercano.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Use this technique to generate and return a random whole number between `0` and `9`.
|
||||
Utiliza esta técnica para generar y devolver un número entero aleatorio entre `0` y `9`.
|
||||
|
||||
# --hints--
|
||||
|
||||
The result of `randomWholeNum` should be a whole number.
|
||||
El resultado de `randomWholeNum` debe ser un número entero.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -39,13 +39,13 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
You should use `Math.random` to generate a random number.
|
||||
Debes usar `Math.random` para generar un número aleatorio.
|
||||
|
||||
```js
|
||||
assert(code.match(/Math.random/g).length >= 1);
|
||||
```
|
||||
|
||||
You should have multiplied the result of `Math.random` by 10 to make it a number that is between zero and nine.
|
||||
Debes haber multiplicado el resultado de `Math.random` por 10 para convertirlo en un número entre cero y nueve.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -54,7 +54,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
You should use `Math.floor` to remove the decimal part of the number.
|
||||
Debes usar `Math.floor` para eliminar la parte decimal del número.
|
||||
|
||||
```js
|
||||
assert(code.match(/Math.floor/g).length >= 1);
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 56533eb9ac21ba0edf2244c6
|
||||
title: Stand in Line
|
||||
title: Permanece en línea
|
||||
challengeType: 1
|
||||
videoUrl: 'https://scrimba.com/c/ca8Q8tP'
|
||||
forumTopicId: 18307
|
||||
@ -9,41 +9,41 @@ dashedName: stand-in-line
|
||||
|
||||
# --description--
|
||||
|
||||
In Computer Science a <dfn>queue</dfn> is an abstract <dfn>Data Structure</dfn> where items are kept in order. New items can be added at the back of the queue and old items are taken off from the front of the queue.
|
||||
En Informática una <dfn>cola</dfn> (queue) es una estructura de datos <dfn>abstracta</dfn> donde los elementos se mantienen en orden. Los nuevos elementos se pueden añadir en la parte posterior de la cola y los elementos antiguos se retiran de la parte delantera de la cola.
|
||||
|
||||
Write a function `nextInLine` which takes an array (`arr`) and a number (`item`) as arguments.
|
||||
Escribe una función `nextInLine` que tome un arreglo (`arr`) y un número (`item`) como argumentos.
|
||||
|
||||
Add the number to the end of the array, then remove the first element of the array.
|
||||
Agrega el número al final del arreglo, luego elimina el primer elemento del arreglo.
|
||||
|
||||
The `nextInLine` function should then return the element that was removed.
|
||||
La función `nextInLine` debe entonces devolver el elemento que fue removido.
|
||||
|
||||
# --hints--
|
||||
|
||||
`nextInLine([], 5)` should return a number.
|
||||
`nextInLine([], 5)` debe devolver un número.
|
||||
|
||||
```js
|
||||
assert.isNumber(nextInLine([], 5));
|
||||
```
|
||||
|
||||
`nextInLine([], 1)` should return `1`
|
||||
`nextInLine([], 1)` debe devolver `1`
|
||||
|
||||
```js
|
||||
assert(nextInLine([], 1) === 1);
|
||||
```
|
||||
|
||||
`nextInLine([2], 1)` should return `2`
|
||||
`nextInLine([2], 1)` debe devolver `2`
|
||||
|
||||
```js
|
||||
assert(nextInLine([2], 1) === 2);
|
||||
```
|
||||
|
||||
`nextInLine([5,6,7,8,9], 1)` should return `5`
|
||||
`nextInLine([5,6,7,8,9], 1)` debe devolver `5`
|
||||
|
||||
```js
|
||||
assert(nextInLine([5, 6, 7, 8, 9], 1) === 5);
|
||||
```
|
||||
|
||||
After `nextInLine(testArr, 10)`, `testArr[4]` should be `10`
|
||||
Después de `nextInLine(testArr, 10)`, `testArr[4]` debe ser igual a `10`
|
||||
|
||||
```js
|
||||
nextInLine(testArr, 10);
|
||||
|
Reference in New Issue
Block a user