chore(i8n,curriculum): processed translations (#41668)
Co-authored-by: Crowdin Bot <support+bot@crowdin.com>
This commit is contained in:
@ -23,7 +23,7 @@ dashedName: change-a-variable-for-a-specific-area
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
assert(
|
assert(
|
||||||
code.match(/.penguin\s*?{[\s\S]*--penguin-belly\s*?:\s*?white\s*?;[\s\S]*}/gi)
|
code.match(/\.penguin\s*?{[\s\S]*(?<!background-color: )--penguin-belly\s*?:\s?white\s*?;[\s\S]*}/gi)
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ La clase `penguin` debe reasignar la variable `--penguin-belly` a `white`.
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
assert(
|
assert(
|
||||||
code.match(/.penguin\s*?{[\s\S]*--penguin-belly\s*?:\s*?white\s*?;[\s\S]*}/gi)
|
code.match(/\.penguin\s*?{[\s\S]*(?<!background-color: )--penguin-belly\s*?:\s?white\s*?;[\s\S]*}/gi)
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -16,7 +16,9 @@ El método `console.log()`, que "imprime" la salida de lo que está dentro de su
|
|||||||
|
|
||||||
Aquí hay un ejemplo para imprimir la cadena `Hello world!` en la consola:
|
Aquí hay un ejemplo para imprimir la cadena `Hello world!` en la consola:
|
||||||
|
|
||||||
`console.log('Hello world!');`
|
```js
|
||||||
|
console.log('Hello world!');
|
||||||
|
```
|
||||||
|
|
||||||
# --instructions--
|
# --instructions--
|
||||||
|
|
||||||
|
@ -10,11 +10,13 @@ dashedName: learn-about-functional-programming
|
|||||||
|
|
||||||
La programación funcional es un estilo de programación donde las soluciones son simples, funciones aisladas, sin ningún efecto secundario fuera del ámbito de la función.
|
La programación funcional es un estilo de programación donde las soluciones son simples, funciones aisladas, sin ningún efecto secundario fuera del ámbito de la función.
|
||||||
|
|
||||||
`INPUT -> PROCESS -> OUTPUT`
|
```js
|
||||||
|
INPUT -> PROCESS -> OUTPUT
|
||||||
|
```
|
||||||
|
|
||||||
La programación funcional se refiere a:
|
La programación funcional se refiere a:
|
||||||
|
|
||||||
1) Funciones aisladas: sin dependencia alguna del estado del programa, que incluye variables globales sujetas a cambios
|
1) Funciones aisladas: sin dependencia alguna del estado del programa, el cual incluye variables globales sujetas a cambios
|
||||||
|
|
||||||
2) Funciones puras: una misma entrada siempre da la misma salida
|
2) Funciones puras: una misma entrada siempre da la misma salida
|
||||||
|
|
||||||
|
@ -14,7 +14,9 @@ Por ejemplo, `addTogether(2, 3)` debe devolver `5` y `addTogether(2)` debe devol
|
|||||||
|
|
||||||
Si se llama a esta función devuelta con un solo argumento, se obtendrá la suma:
|
Si se llama a esta función devuelta con un solo argumento, se obtendrá la suma:
|
||||||
|
|
||||||
`var sumTwoAnd = addTogether(2);`
|
```js
|
||||||
|
var sumTwoAnd = addTogether(2);
|
||||||
|
```
|
||||||
|
|
||||||
`sumTwoAnd(3)` devuelve `5`.
|
`sumTwoAnd(3)` devuelve `5`.
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
id: 587d7dad367417b2b2512b77
|
id: 587d7dad367417b2b2512b77
|
||||||
title: Define a Constructor Function
|
title: Define una función "Constructor"
|
||||||
challengeType: 1
|
challengeType: 1
|
||||||
forumTopicId: 16804
|
forumTopicId: 16804
|
||||||
dashedName: define-a-constructor-function
|
dashedName: define-a-constructor-function
|
||||||
@ -8,9 +8,9 @@ dashedName: define-a-constructor-function
|
|||||||
|
|
||||||
# --description--
|
# --description--
|
||||||
|
|
||||||
<dfn>Constructors</dfn> are functions that create new objects. They define properties and behaviors that will belong to the new object. Think of them as a blueprint for the creation of new objects.
|
Las funciones <dfn>Constructors</dfn> crean nuevos objetos. Definen propiedades y comportamientos que pertenecerán al nuevo objeto. Piensa que son el modelo para la creación de nuevos objetos.
|
||||||
|
|
||||||
Here is an example of a constructor:
|
A continuación se muestra un ejemplo de un constructor:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
function Bird() {
|
function Bird() {
|
||||||
@ -20,29 +20,29 @@ function Bird() {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
This constructor defines a `Bird` object with properties `name`, `color`, and `numLegs` set to Albert, blue, and 2, respectively. Constructors follow a few conventions:
|
Este constructor define un objeto `Bird` con las propiedades `name`, `color` y `numLegs` establecidas a Albert, blue y 2 respectivamente. Los constructores tienen las siguientes convenciones:
|
||||||
|
|
||||||
<ul><li>Constructors are defined with a capitalized name to distinguish them from other functions that are not <code>constructors</code>.</li><li>Constructors use the keyword <code>this</code> to set properties of the object they will create. Inside the constructor, <code>this</code> refers to the new object it will create.</li><li>Constructors define properties and behaviors instead of returning a value as other functions might.</li></ul>
|
<ul><li>Están definidos con un nombre en mayúscula para distinguirlos de otras funciones que no son <code>constructors</code>.</li><li>Utilizan la palabra clave <code>this</code> para establecer propiedades del objeto que crearán. Dentro del constructor, <code>this</code> se refiere al nuevo objeto que creará.</li><li>Los Constructors definen propiedades y comportamientos en ves de devolverlos como un valor como lo harían otras funciones.</li></ul>
|
||||||
|
|
||||||
# --instructions--
|
# --instructions--
|
||||||
|
|
||||||
Create a constructor, `Dog`, with properties `name`, `color`, and `numLegs` that are set to a string, a string, and a number, respectively.
|
Crea un constructor, `Dog`, con las propiedades `name`, `color` y `numLegs` que se establecen a una cadena, una cadena y un número respectivamente.
|
||||||
|
|
||||||
# --hints--
|
# --hints--
|
||||||
|
|
||||||
`Dog` should have a `name` property set to a string.
|
`Dog` debe tener una propiedad `name` establecida a una cadena.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(typeof new Dog().name === 'string');
|
assert(typeof new Dog().name === 'string');
|
||||||
```
|
```
|
||||||
|
|
||||||
`Dog` should have a `color` property set to a string.
|
`Dog` debe tener una propiedad `color` establecida a una cadena.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(typeof new Dog().color === 'string');
|
assert(typeof new Dog().color === 'string');
|
||||||
```
|
```
|
||||||
|
|
||||||
`Dog` should have a `numLegs` property set to a number.
|
`Dog` debe tener una propiedad `numLegs` establecida a un número.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(typeof new Dog().numLegs === 'number');
|
assert(typeof new Dog().numLegs === 'number');
|
||||||
@ -51,7 +51,9 @@ assert(typeof new Dog().numLegs === 'number');
|
|||||||
# --seed--
|
# --seed--
|
||||||
|
|
||||||
## --seed-contents--
|
## --seed-contents--
|
||||||
|
|
||||||
```js
|
```js
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
# --solutions--
|
# --solutions--
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
id: 587d7dad367417b2b2512b76
|
id: 587d7dad367417b2b2512b76
|
||||||
title: Make Code More Reusable with the this Keyword
|
title: Haz el código más reutilizable con la palabra clave "this"
|
||||||
challengeType: 1
|
challengeType: 1
|
||||||
forumTopicId: 301321
|
forumTopicId: 301321
|
||||||
dashedName: make-code-more-reusable-with-the-this-keyword
|
dashedName: make-code-more-reusable-with-the-this-keyword
|
||||||
@ -8,13 +8,15 @@ dashedName: make-code-more-reusable-with-the-this-keyword
|
|||||||
|
|
||||||
# --description--
|
# --description--
|
||||||
|
|
||||||
The last challenge introduced a method to the `duck` object. It used `duck.name` dot notation to access the value for the `name` property within the return statement:
|
El último desafío introdujo un método al objeto `duck`. Usó la notación de puntos `duck.name` para acceder al valor de la propiedad `name` dentro de la declaración de retorno:
|
||||||
|
|
||||||
`sayName: function() {return "The name of this duck is " + duck.name + ".";}`
|
```js
|
||||||
|
sayName: function() {return "The name of this duck is " + duck.name + ".";}
|
||||||
|
```
|
||||||
|
|
||||||
While this is a valid way to access the object's property, there is a pitfall here. If the variable name changes, any code referencing the original name would need to be updated as well. In a short object definition, it isn't a problem, but if an object has many references to its properties there is a greater chance for error.
|
Aunque esta es una forma válida de acceder a la propiedad del objeto, existe un problema. Si el nombre de la variable cambia, cualquier código que haga referencia al nombre original también tendría que ser actualizado. En una definición breve de un objeto, esto no es un problema, pero si un objeto tiene muchas referencias a sus propiedades hay una mayor probabilidad de error.
|
||||||
|
|
||||||
A way to avoid these issues is with the `this` keyword:
|
Una forma de evitar estos problemas es con palabra clave `this`:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
let duck = {
|
let duck = {
|
||||||
@ -24,21 +26,21 @@ let duck = {
|
|||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
`this` is a deep topic, and the above example is only one way to use it. In the current context, `this` refers to the object that the method is associated with: `duck`. If the object's name is changed to `mallard`, it is not necessary to find all the references to `duck` in the code. It makes the code reusable and easier to read.
|
`this` es un tema profundo, y el ejemplo anterior es sólo una forma de usarlo. En el contexto actual, `this` se refiere al objeto con el que el método está asociado: `duck`. Si el nombre del objeto se cambia a `mallard`, no es necesario encontrar todas las referencias a `duck` en el código. Hace que el código sea reutilizable y mas fácil de leer.
|
||||||
|
|
||||||
# --instructions--
|
# --instructions--
|
||||||
|
|
||||||
Modify the `dog.sayLegs` method to remove any references to `dog`. Use the `duck` example for guidance.
|
Modifica el método `dog.sayLegs` para eliminar cualquier referencia a `dog`. Utiliza el ejemplo de `duck` como orientación.
|
||||||
|
|
||||||
# --hints--
|
# --hints--
|
||||||
|
|
||||||
`dog.sayLegs()` should return the given string.
|
`dog.sayLegs()` debe devolver una cadena.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(dog.sayLegs() === 'This dog has 4 legs.');
|
assert(dog.sayLegs() === 'This dog has 4 legs.');
|
||||||
```
|
```
|
||||||
|
|
||||||
Your code should use the `this` keyword to access the `numLegs` property of `dog`.
|
Tu código debe usar la palabra clave `this` para acceder a la propiedad `numLegs` de `dog`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(code.match(/this\.numLegs/g));
|
assert(code.match(/this\.numLegs/g));
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
id: 587d7daf367417b2b2512b7e
|
id: 587d7daf367417b2b2512b7e
|
||||||
title: Understand the Constructor Property
|
title: Entiende la propiedad constructor
|
||||||
challengeType: 1
|
challengeType: 1
|
||||||
forumTopicId: 301327
|
forumTopicId: 301327
|
||||||
dashedName: understand-the-constructor-property
|
dashedName: understand-the-constructor-property
|
||||||
@ -8,17 +8,19 @@ dashedName: understand-the-constructor-property
|
|||||||
|
|
||||||
# --description--
|
# --description--
|
||||||
|
|
||||||
There is a special `constructor` property located on the object instances `duck` and `beagle` that were created in the previous challenges:
|
Hay una propiedad especial `constructor` ubicada en instancias de objeto `duck` y `beagle` que fueron creados en desafíos anteriores:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
let duck = new Bird();
|
let duck = new Bird();
|
||||||
let beagle = new Dog();
|
let beagle = new Dog();
|
||||||
|
|
||||||
console.log(duck.constructor === Bird); //prints true
|
console.log(duck.constructor === Bird);
|
||||||
console.log(beagle.constructor === Dog); //prints true
|
console.log(beagle.constructor === Dog);
|
||||||
```
|
```
|
||||||
|
|
||||||
Note that the `constructor` property is a reference to the constructor function that created the instance. The advantage of the `constructor` property is that it's possible to check for this property to find out what kind of object it is. Here's an example of how this could be used:
|
Ambas llamadas `console.log` devolverían `true` en la consola.
|
||||||
|
|
||||||
|
Ten en cuenta que la propiedad `constructor` hace referencia a la función constructor que creo la instancia. La ventaja de la propiedad `constructor` es que es posible verificar esta propiedad para averiguar qué tipo de objeto es. Así es como se podría utilizar:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
function joinBirdFraternity(candidate) {
|
function joinBirdFraternity(candidate) {
|
||||||
@ -30,28 +32,27 @@ function joinBirdFraternity(candidate) {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
**Note**
|
**Nota:** dado que la propiedad `constructor` se puede sobreescribir (se verá en los próximos dos desafíos), por lo general, es mejor utilizar el método `instanceof` para verificar el tipo de un objeto.
|
||||||
Since the `constructor` property can be overwritten (which will be covered in the next two challenges) it’s generally better to use the `instanceof` method to check the type of an object.
|
|
||||||
|
|
||||||
# --instructions--
|
# --instructions--
|
||||||
|
|
||||||
Write a `joinDogFraternity` function that takes a `candidate` parameter and, using the `constructor` property, return `true` if the candidate is a `Dog`, otherwise return `false`.
|
Escribe una función `joinDogFraternity` que tome como parámetro `candidate` y que con la propiedad `constructor`, devuelva `true` si el candidato es un `Dog` y si no lo es debería devolver `false`.
|
||||||
|
|
||||||
# --hints--
|
# --hints--
|
||||||
|
|
||||||
`joinDogFraternity` should be defined as a function.
|
`joinDogFraternity` debe definirse como una función.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(typeof joinDogFraternity === 'function');
|
assert(typeof joinDogFraternity === 'function');
|
||||||
```
|
```
|
||||||
|
|
||||||
`joinDogFraternity` should return true if`candidate` is an instance of `Dog`.
|
`joinDogFraternity` debe devolver `true` si `candidate` es una instancia de `Dog`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(joinDogFraternity(new Dog('')) === true);
|
assert(joinDogFraternity(new Dog('')) === true);
|
||||||
```
|
```
|
||||||
|
|
||||||
`joinDogFraternity` should use the `constructor` property.
|
`joinDogFraternity` debe utilizar la propiedad `constructor`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(/\.constructor/.test(code) && !/instanceof/.test(code));
|
assert(/\.constructor/.test(code) && !/instanceof/.test(code));
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
id: 587d7db2367417b2b2512b8b
|
id: 587d7db2367417b2b2512b8b
|
||||||
title: Understand the Immediately Invoked Function Expression (IIFE)
|
title: Comprende las funciones que son invocadas inmediatamente (IIFE)
|
||||||
challengeType: 1
|
challengeType: 1
|
||||||
forumTopicId: 301328
|
forumTopicId: 301328
|
||||||
dashedName: understand-the-immediately-invoked-function-expression-iife
|
dashedName: understand-the-immediately-invoked-function-expression-iife
|
||||||
@ -8,30 +8,31 @@ dashedName: understand-the-immediately-invoked-function-expression-iife
|
|||||||
|
|
||||||
# --description--
|
# --description--
|
||||||
|
|
||||||
A common pattern in JavaScript is to execute a function as soon as it is declared:
|
Un patrón común en JavaScript es la ejecución de una función apenas declarada:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
(function () {
|
(function () {
|
||||||
console.log("Chirp, chirp!");
|
console.log("Chirp, chirp!");
|
||||||
})(); // this is an anonymous function expression that executes right away
|
})();
|
||||||
// Outputs "Chirp, chirp!" immediately
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Note that the function has no name and is not stored in a variable. The two parentheses () at the end of the function expression cause it to be immediately executed or invoked. This pattern is known as an <dfn>immediately invoked function expression</dfn> or <dfn>IIFE</dfn>.
|
Esta es una expresión de función anónima que se ejecuta de inmediato y produce `Chirp, chirp!` inmediatamente.
|
||||||
|
|
||||||
|
Ten en cuenta que la función no tiene nombre y que no se almacena en un valor. Los dos paréntesis () al final de la expresión de la función hacen que se ejecute o invoque de forma inmediata. Este patrón se conoce como una <dfn>expresión de función inmediatamente invocada</dfn> o <dfn>IIFE (por sus siglas en inglés)</dfn>.
|
||||||
|
|
||||||
# --instructions--
|
# --instructions--
|
||||||
|
|
||||||
Rewrite the function `makeNest` and remove its call so instead it's an anonymous immediately invoked function expression (IIFE).
|
Reescribe la función `makeNest` y elimina su llamada, por lo que es una expresión de función anónima inmediatamente invocada (IIFE).
|
||||||
|
|
||||||
# --hints--
|
# --hints--
|
||||||
|
|
||||||
The function should be anonymous.
|
La función debe ser anónima.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(/\((function|\(\))(=>|\(\)){?/.test(code.replace(/\s/g, '')));
|
assert(/\((function|\(\))(=>|\(\)){?/.test(code.replace(/\s/g, '')));
|
||||||
```
|
```
|
||||||
|
|
||||||
Your function should have parentheses at the end of the expression to call it immediately.
|
Tu función debe tener paréntesis al final de la expresión para llamarle de inmediato.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(/\(.*(\)\(|\}\(\))\)/.test(code.replace(/[\s;]/g, '')));
|
assert(/\(.*(\)\(|\}\(\))\)/.test(code.replace(/[\s;]/g, '')));
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
id: 587d7db0367417b2b2512b82
|
id: 587d7db0367417b2b2512b82
|
||||||
title: Understand the Prototype Chain
|
title: Comprende la cadena "prototype"
|
||||||
challengeType: 1
|
challengeType: 1
|
||||||
forumTopicId: 301329
|
forumTopicId: 301329
|
||||||
dashedName: understand-the-prototype-chain
|
dashedName: understand-the-prototype-chain
|
||||||
@ -8,38 +8,38 @@ dashedName: understand-the-prototype-chain
|
|||||||
|
|
||||||
# --description--
|
# --description--
|
||||||
|
|
||||||
All objects in JavaScript (with a few exceptions) have a `prototype`. Also, an object’s `prototype` itself is an object.
|
Todos los objetos en JavaScript (con algunas excepciones) tienen un `prototype`. Además, el `prototype` de un objeto en sí mismo es un objeto.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
function Bird(name) {
|
function Bird(name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
typeof Bird.prototype; // yields 'object'
|
typeof Bird.prototype;
|
||||||
```
|
```
|
||||||
|
|
||||||
Because a `prototype` is an object, a `prototype` can have its own `prototype`! In this case, the `prototype` of `Bird.prototype` is `Object.prototype`:
|
Debido a que `prototype` es un objeto, ¡un`prototype` puede tener su propio `prototype`! En este caso, el `prototype` de `Bird.prototype` es `Object.prototype`:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
Object.prototype.isPrototypeOf(Bird.prototype); // returns true
|
Object.prototype.isPrototypeOf(Bird.prototype);
|
||||||
```
|
```
|
||||||
|
|
||||||
How is this useful? You may recall the `hasOwnProperty` method from a previous challenge:
|
¿Por qué sería útil? Quizás recuerdes el método `hasOwnProperty` del desafío pasado:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
let duck = new Bird("Donald");
|
let duck = new Bird("Donald");
|
||||||
duck.hasOwnProperty("name"); // yields true
|
duck.hasOwnProperty("name");
|
||||||
```
|
```
|
||||||
|
|
||||||
The `hasOwnProperty` method is defined in `Object.prototype`, which can be accessed by `Bird.prototype`, which can then be accessed by `duck`. This is an example of the `prototype` chain. In this `prototype` chain, `Bird` is the `supertype` for `duck`, while `duck` is the `subtype`. `Object` is a `supertype` for both `Bird` and `duck`. `Object` is a `supertype` for all objects in JavaScript. Therefore, any object can use the `hasOwnProperty` method.
|
El método `hasOwnProperty` se define en `Object.prototype` al cual se puede acceder con `Bird.prototype`, al que se puede acceder con `duck`. Este es un ejemplo de la cadena `prototype`. En esta cadena `prototype`, `Bird` es el `supertype` de `duck` mientras que `duck` es el `subtype`. `Object` es un `supertype` de `Bird` y `duck`. `Object` es un `supertype` de todos los objetos en JavaScript. Por lo tanto, cualquier objeto puede utilizar el método `hasOwnProperty`.
|
||||||
|
|
||||||
# --instructions--
|
# --instructions--
|
||||||
|
|
||||||
Modify the code to show the correct prototype chain.
|
Modifica el código para mostrar la cadena de prototipos correcta.
|
||||||
|
|
||||||
# --hints--
|
# --hints--
|
||||||
|
|
||||||
Your code should show that `Object.prototype` is the prototype of `Dog.prototype`
|
El código debe mostrar que `Object.prototype` es el prototipo de `Dog.prototype`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(/Object\.prototype\.isPrototypeOf/.test(code));
|
assert(/Object\.prototype\.isPrototypeOf/.test(code));
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
id: 587d7db0367417b2b2512b81
|
id: 587d7db0367417b2b2512b81
|
||||||
title: Understand Where an Object’s Prototype Comes From
|
title: Entendiendo de dónde viene el prototipo de un objeto
|
||||||
challengeType: 1
|
challengeType: 1
|
||||||
forumTopicId: 301330
|
forumTopicId: 301330
|
||||||
dashedName: understand-where-an-objects-prototype-comes-from
|
dashedName: understand-where-an-objects-prototype-comes-from
|
||||||
@ -8,7 +8,7 @@ dashedName: understand-where-an-objects-prototype-comes-from
|
|||||||
|
|
||||||
# --description--
|
# --description--
|
||||||
|
|
||||||
Just like people inherit genes from their parents, an object inherits its `prototype` directly from the constructor function that created it. For example, here the `Bird` constructor creates the `duck` object:
|
Así como las personas heredamos genes de nuestros padres, los objetos también heredan su `prototype` directamente de la función constructor que lo creó. Por ejemplo, aquí el constructor `Bird` crea el objeto `duck`:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
function Bird(name) {
|
function Bird(name) {
|
||||||
@ -18,20 +18,21 @@ function Bird(name) {
|
|||||||
let duck = new Bird("Donald");
|
let duck = new Bird("Donald");
|
||||||
```
|
```
|
||||||
|
|
||||||
`duck` inherits its `prototype` from the `Bird` constructor function. You can show this relationship with the `isPrototypeOf` method:
|
`duck` hereda su `prototype` de la función constructor `Bird`. Puedes mostrar esta relación con el método `isPrototypeOf`:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
Bird.prototype.isPrototypeOf(duck);
|
Bird.prototype.isPrototypeOf(duck);
|
||||||
// returns true
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Este devolvería `true`.
|
||||||
|
|
||||||
# --instructions--
|
# --instructions--
|
||||||
|
|
||||||
Use `isPrototypeOf` to check the `prototype` of `beagle`.
|
Utiliza `isPrototypeOf` para comprobar el `prototype` de `beagle`.
|
||||||
|
|
||||||
# --hints--
|
# --hints--
|
||||||
|
|
||||||
You should show that `Dog.prototype` is the `prototype` of `beagle`
|
Debes mostrar que `Dog.prototype` es el `prototype` de `beagle`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(/Dog\.prototype\.isPrototypeOf\(beagle\)/.test(code));
|
assert(/Dog\.prototype\.isPrototypeOf\(beagle\)/.test(code));
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
id: 587d7dad367417b2b2512b78
|
id: 587d7dad367417b2b2512b78
|
||||||
title: Use a Constructor to Create Objects
|
title: Utiliza un constructor para crear objetos
|
||||||
challengeType: 1
|
challengeType: 1
|
||||||
forumTopicId: 18233
|
forumTopicId: 18233
|
||||||
dashedName: use-a-constructor-to-create-objects
|
dashedName: use-a-constructor-to-create-objects
|
||||||
@ -8,47 +8,48 @@ dashedName: use-a-constructor-to-create-objects
|
|||||||
|
|
||||||
# --description--
|
# --description--
|
||||||
|
|
||||||
Here's the `Bird` constructor from the previous challenge:
|
Aquí tenemos el constructor `Bird` del desafío anterior:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
function Bird() {
|
function Bird() {
|
||||||
this.name = "Albert";
|
this.name = "Albert";
|
||||||
this.color = "blue";
|
this.color = "blue";
|
||||||
this.numLegs = 2;
|
this.numLegs = 2;
|
||||||
// "this" inside the constructor always refers to the object being created
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let blueBird = new Bird();
|
let blueBird = new Bird();
|
||||||
```
|
```
|
||||||
|
|
||||||
Notice that the `new` operator is used when calling a constructor. This tells JavaScript to create a new instance of `Bird` called `blueBird`. Without the `new` operator, `this` inside the constructor would not point to the newly created object, giving unexpected results. Now `blueBird` has all the properties defined inside the `Bird` constructor:
|
**NOTA:** `this` dentro del constructor siempre se refiere al objeto que se está creando.
|
||||||
|
|
||||||
|
Observa que se utiliza el operador `new` cuando llamamos a un constructor. Esto le indica a JavaScript que cree una nueva instancia de `Bird` llamada `blueBird`. Sin el operador `new`, dentro del constructor `this` no haría referencia al nuevo objeto, dando resultados inesperados. Ahora `blueBird` tiene todas las propiedades definidas dentro del constructor `Bird`:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
blueBird.name; // => Albert
|
blueBird.name;
|
||||||
blueBird.color; // => blue
|
blueBird.color;
|
||||||
blueBird.numLegs; // => 2
|
blueBird.numLegs;
|
||||||
```
|
```
|
||||||
|
|
||||||
Just like any other object, its properties can be accessed and modified:
|
Al igual que cualquier otro objeto, sus propiedades pueden ser accedidas y modificadas:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
blueBird.name = 'Elvira';
|
blueBird.name = 'Elvira';
|
||||||
blueBird.name; // => Elvira
|
blueBird.name;
|
||||||
```
|
```
|
||||||
|
|
||||||
# --instructions--
|
# --instructions--
|
||||||
|
|
||||||
Use the `Dog` constructor from the last lesson to create a new instance of `Dog`, assigning it to a variable `hound`.
|
Utiliza el constructor `Dog` de la última lección para crear una nueva instancia de `Dog`, asignándolo a una variable `hound`.
|
||||||
|
|
||||||
# --hints--
|
# --hints--
|
||||||
|
|
||||||
`hound` should be created using the `Dog` constructor.
|
`hound` debe ser creado usando el constructor `Dog`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(hound instanceof Dog);
|
assert(hound instanceof Dog);
|
||||||
```
|
```
|
||||||
|
|
||||||
Your code should use the `new` operator to create an instance of `Dog`.
|
Tu código debe usar el operador `new` para crear una instancia de `Dog`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(code.match(/new/g));
|
assert(code.match(/new/g));
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
id: 587d7db2367417b2b2512b89
|
id: 587d7db2367417b2b2512b89
|
||||||
title: Use a Mixin to Add Common Behavior Between Unrelated Objects
|
title: Utiliza un "mixin" para añadir un comportamiento común entre objetos no relacionados
|
||||||
challengeType: 1
|
challengeType: 1
|
||||||
forumTopicId: 301331
|
forumTopicId: 301331
|
||||||
dashedName: use-a-mixin-to-add-common-behavior-between-unrelated-objects
|
dashedName: use-a-mixin-to-add-common-behavior-between-unrelated-objects
|
||||||
@ -8,9 +8,9 @@ dashedName: use-a-mixin-to-add-common-behavior-between-unrelated-objects
|
|||||||
|
|
||||||
# --description--
|
# --description--
|
||||||
|
|
||||||
As you have seen, behavior is shared through inheritance. However, there are cases when inheritance is not the best solution. Inheritance does not work well for unrelated objects like `Bird` and `Airplane`. They can both fly, but a `Bird` is not a type of `Airplane` and vice versa.
|
Como ya has visto, el comportamiento se comparte mediante una herencia. Sin embargo, hay algunos casos en los que la herencia no es la mejor opción. La herencia no funciona bien con objetos que no están relacionados como `Bird` y `Airplane`. Ambos pueden volar pero un `Bird` no es un tipo de `Airplane` y viceversa.
|
||||||
|
|
||||||
For unrelated objects, it's better to use <dfn>mixins</dfn>. A mixin allows other objects to use a collection of functions.
|
Para objetos no relacionados es mejor utilizar <dfn>mixins</dfn>. Un "mixin" permite a otros objetos utilizar una colección de funciones.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
let flyMixin = function(obj) {
|
let flyMixin = function(obj) {
|
||||||
@ -20,7 +20,7 @@ let flyMixin = function(obj) {
|
|||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
The `flyMixin` takes any object and gives it the `fly` method.
|
El `flyMixin` toma a cualquier objeto y le da el método `fly`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
let bird = {
|
let bird = {
|
||||||
@ -37,34 +37,36 @@ flyMixin(bird);
|
|||||||
flyMixin(plane);
|
flyMixin(plane);
|
||||||
```
|
```
|
||||||
|
|
||||||
Here `bird` and `plane` are passed into `flyMixin`, which then assigns the `fly` function to each object. Now `bird` and `plane` can both fly:
|
Aquí `bird` y `plane` son pasados a `flyMixin` el cual después asigna la función `fly` a cada objeto. Ahora `bird` y `plane` pueden volar:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
bird.fly(); // prints "Flying, wooosh!"
|
bird.fly();
|
||||||
plane.fly(); // prints "Flying, wooosh!"
|
plane.fly();
|
||||||
```
|
```
|
||||||
|
|
||||||
Note how the mixin allows for the same `fly` method to be reused by unrelated objects `bird` and `plane`.
|
La consola mostraría la cadena `Flying, wooosh!` dos veces, una por cada llamada a `.fly()`.
|
||||||
|
|
||||||
|
Ten en cuenta cómo el mixin permite que el mismo método `fly` sea reutilizado por los objetos `bird` y `plane` los cuales no están relacionados.
|
||||||
|
|
||||||
# --instructions--
|
# --instructions--
|
||||||
|
|
||||||
Create a mixin named `glideMixin` that defines a method named `glide`. Then use the `glideMixin` to give both `bird` and `boat` the ability to glide.
|
Crea un mixin llamado `glideMixin` que defina un método llamado `glide`. Luego utiliza el `glideMixin` para dar a `bird` y `boat` la habilidad de planear.
|
||||||
|
|
||||||
# --hints--
|
# --hints--
|
||||||
|
|
||||||
Your code should declare a `glideMixin` variable that is a function.
|
El código debe declarar una variable `glideMixin` que sea una función.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(typeof glideMixin === 'function');
|
assert(typeof glideMixin === 'function');
|
||||||
```
|
```
|
||||||
|
|
||||||
Your code should use the `glideMixin` on the `bird` object to give it the `glide` method.
|
El código debe usar el `glideMixin` en el objeto `bird` para darle el método `glide` (planear).
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(typeof bird.glide === 'function');
|
assert(typeof bird.glide === 'function');
|
||||||
```
|
```
|
||||||
|
|
||||||
Your code should use the `glideMixin` on the `boat` object to give it the `glide` method.
|
El código debe usar el `glideMixin` en el objeto `boat` para darle el método `glide` (planear).
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(typeof boat.glide === 'function');
|
assert(typeof boat.glide === 'function');
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
id: 587d7db2367417b2b2512b8c
|
id: 587d7db2367417b2b2512b8c
|
||||||
title: Use an IIFE to Create a Module
|
title: Utiliza una IIFE para crear un módulo
|
||||||
challengeType: 1
|
challengeType: 1
|
||||||
forumTopicId: 301332
|
forumTopicId: 301332
|
||||||
dashedName: use-an-iife-to-create-a-module
|
dashedName: use-an-iife-to-create-a-module
|
||||||
@ -8,7 +8,7 @@ dashedName: use-an-iife-to-create-a-module
|
|||||||
|
|
||||||
# --description--
|
# --description--
|
||||||
|
|
||||||
An immediately invoked function expression (IIFE) is often used to group related functionality into a single object or <dfn>module</dfn>. For example, an earlier challenge defined two mixins:
|
Una expresión de función inmediatamente invocada (IIFE) se utiliza a menudo para agrupar la funcionalidad relacionada en un solo objeto o <dfn>módulo</dfn>. Por ejemplo, en el desafío anterior se definieron dos "mixins":
|
||||||
|
|
||||||
```js
|
```js
|
||||||
function glideMixin(obj) {
|
function glideMixin(obj) {
|
||||||
@ -23,7 +23,7 @@ function flyMixin(obj) {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
We can group these mixins into a module as follows:
|
Podemos agrupar estos mixins en un módulo:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
let motionModule = (function () {
|
let motionModule = (function () {
|
||||||
@ -39,10 +39,10 @@ let motionModule = (function () {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})(); // The two parentheses cause the function to be immediately invoked
|
})();
|
||||||
```
|
```
|
||||||
|
|
||||||
Note that you have an immediately invoked function expression (IIFE) that returns an object `motionModule`. This returned object contains all of the mixin behaviors as properties of the object. The advantage of the module pattern is that all of the motion behaviors can be packaged into a single object that can then be used by other parts of your code. Here is an example using it:
|
Ten en cuenta que has invocado una IIFE que devuelve un objeto `motionModule`. El objeto devuelto contiene todos los comportamientos de los mixins como propiedades del objeto. La ventaja del patrón del módulo es que todos los comportamientos de movimiento pueden ser empaquetados en un solo objeto que puede ser usado por otras partes del código. Así se debe utilizar:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
motionModule.glideMixin(duck);
|
motionModule.glideMixin(duck);
|
||||||
@ -51,23 +51,23 @@ duck.glide();
|
|||||||
|
|
||||||
# --instructions--
|
# --instructions--
|
||||||
|
|
||||||
Create a module named `funModule` to wrap the two mixins `isCuteMixin` and `singMixin`. `funModule` should return an object.
|
Crea un módulo llamado `funModule` para envolver los dos mixins `isCuteMixin` y `singMixin`. `funModule` debe devolver un objeto.
|
||||||
|
|
||||||
# --hints--
|
# --hints--
|
||||||
|
|
||||||
`funModule` should be defined and return an object.
|
`funModule` debe ser definido y devolver un objeto.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(typeof funModule === 'object');
|
assert(typeof funModule === 'object');
|
||||||
```
|
```
|
||||||
|
|
||||||
`funModule.isCuteMixin` should access a function.
|
`funModule.isCuteMixin` debe acceder a una función.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(typeof funModule.isCuteMixin === 'function');
|
assert(typeof funModule.isCuteMixin === 'function');
|
||||||
```
|
```
|
||||||
|
|
||||||
`funModule.singMixin` should access a function.
|
`funModule.singMixin` debe acceder a una función.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(typeof funModule.singMixin === 'function');
|
assert(typeof funModule.singMixin === 'function');
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
id: 587d7dac367417b2b2512b74
|
id: 587d7dac367417b2b2512b74
|
||||||
title: Use Dot Notation to Access the Properties of an Object
|
title: Utiliza notación de puntos para acceder a las propiedades de un objeto
|
||||||
challengeType: 1
|
challengeType: 1
|
||||||
forumTopicId: 301333
|
forumTopicId: 301333
|
||||||
dashedName: use-dot-notation-to-access-the-properties-of-an-object
|
dashedName: use-dot-notation-to-access-the-properties-of-an-object
|
||||||
@ -8,7 +8,7 @@ dashedName: use-dot-notation-to-access-the-properties-of-an-object
|
|||||||
|
|
||||||
# --description--
|
# --description--
|
||||||
|
|
||||||
The last challenge created an object with various properties. Now you'll see how to access the values of those properties. Here's an example:
|
En el último desafío creaste un objeto con varias propiedades. Ahora verás cómo acceder a los valores de esas propiedades. Por ejemplo:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
let duck = {
|
let duck = {
|
||||||
@ -16,24 +16,23 @@ let duck = {
|
|||||||
numLegs: 2
|
numLegs: 2
|
||||||
};
|
};
|
||||||
console.log(duck.name);
|
console.log(duck.name);
|
||||||
// This prints "Aflac" to the console
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Dot notation is used on the object name, `duck`, followed by the name of the property, `name`, to access the value of "Aflac".
|
Se utiliza notación de puntos con el nombre del objeto, `duck`, seguido por el nombre de la propiedad, `name`, para acceder al valor de `Aflac`.
|
||||||
|
|
||||||
# --instructions--
|
# --instructions--
|
||||||
|
|
||||||
Print both properties of the `dog` object to your console.
|
Imprime ambas propiedades del objeto `dog` en tu consola.
|
||||||
|
|
||||||
# --hints--
|
# --hints--
|
||||||
|
|
||||||
Your code should use `console.log` to print the value for the `name` property of the `dog` object.
|
Tu código debe usar `console.log` para imprimir el valor de la propiedad `name` del objeto `dog`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(/console.log\(.*dog\.name.*\)/g.test(code));
|
assert(/console.log\(.*dog\.name.*\)/g.test(code));
|
||||||
```
|
```
|
||||||
|
|
||||||
Your code should use `console.log` to print the value for the `numLegs` property of the `dog` object.
|
Tu código debe usar `console.log` para imprimir el valor de la propiedad `numLegs` del objeto `dog`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(/console.log\(.*dog\.numLegs.*\)/g.test(code));
|
assert(/console.log\(.*dog\.numLegs.*\)/g.test(code));
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
id: 587d7dae367417b2b2512b7a
|
id: 587d7dae367417b2b2512b7a
|
||||||
title: Verify an Object's Constructor with instanceof
|
title: Verifica el constructor de un objeto con "instanceof"
|
||||||
challengeType: 1
|
challengeType: 1
|
||||||
forumTopicId: 301337
|
forumTopicId: 301337
|
||||||
dashedName: verify-an-objects-constructor-with-instanceof
|
dashedName: verify-an-objects-constructor-with-instanceof
|
||||||
@ -8,7 +8,7 @@ dashedName: verify-an-objects-constructor-with-instanceof
|
|||||||
|
|
||||||
# --description--
|
# --description--
|
||||||
|
|
||||||
Anytime a constructor function creates a new object, that object is said to be an <dfn>instance</dfn> of its constructor. JavaScript gives a convenient way to verify this with the `instanceof` operator. `instanceof` allows you to compare an object to a constructor, returning `true` or `false` based on whether or not that object was created with the constructor. Here's an example:
|
Cada vez que una función constructora crea un nuevo objeto, se dice que ese objeto es una <dfn>instancia</dfn> de su constructor. JavaScript proporciona una manera conveniente de verificar esto con el operador `instanceof`. `instanceof` permite comparar un objeto con un constructor, devuelve `true` o `false` basado en si ese objeto fue creado o no con dicho constructor. Aquí hay un ejemplo:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
let Bird = function(name, color) {
|
let Bird = function(name, color) {
|
||||||
@ -19,10 +19,12 @@ let Bird = function(name, color) {
|
|||||||
|
|
||||||
let crow = new Bird("Alexis", "black");
|
let crow = new Bird("Alexis", "black");
|
||||||
|
|
||||||
crow instanceof Bird; // => true
|
crow instanceof Bird;
|
||||||
```
|
```
|
||||||
|
|
||||||
If an object is created without using a constructor, `instanceof` will verify that it is not an instance of that constructor:
|
Aquí el método `instanceof` devolverá `true`.
|
||||||
|
|
||||||
|
Si un objeto es creado sin usar un constructor, `instanceof` verificará que no es una instancia de ese constructor:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
let canary = {
|
let canary = {
|
||||||
@ -31,22 +33,24 @@ let canary = {
|
|||||||
numLegs: 2
|
numLegs: 2
|
||||||
};
|
};
|
||||||
|
|
||||||
canary instanceof Bird; // => false
|
canary instanceof Bird;
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Aquí el método `instanceof` devolverá `false`.
|
||||||
|
|
||||||
# --instructions--
|
# --instructions--
|
||||||
|
|
||||||
Create a new instance of the `House` constructor, calling it `myHouse` and passing a number of bedrooms. Then, use `instanceof` to verify that it is an instance of `House`.
|
Crea una nueva instancia del constructor `House`, llamándola `myHouse` y pasando el número de habitaciones. Luego, usa `instanceof` para verificar que es una instancia de `House`.
|
||||||
|
|
||||||
# --hints--
|
# --hints--
|
||||||
|
|
||||||
`myHouse` should have a `numBedrooms` attribute set to a number.
|
`myHouse` debe tener un atributo `numBedrooms` establecido a un número.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(typeof myHouse.numBedrooms === 'number');
|
assert(typeof myHouse.numBedrooms === 'number');
|
||||||
```
|
```
|
||||||
|
|
||||||
You should verify that `myHouse` is an instance of `House` using the `instanceof` operator.
|
Debes verificar que `myHouse` es una instancia de `House` usando el operador `instanceof`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(/myHouse\s*instanceof\s*House/.test(code));
|
assert(/myHouse\s*instanceof\s*House/.test(code));
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
id: 587d7db3367417b2b2512b8f
|
id: 587d7db3367417b2b2512b8f
|
||||||
title: Match Literal Strings
|
title: Haz coincidir cadenas literales
|
||||||
challengeType: 1
|
challengeType: 1
|
||||||
forumTopicId: 301355
|
forumTopicId: 301355
|
||||||
dashedName: match-literal-strings
|
dashedName: match-literal-strings
|
||||||
@ -8,44 +8,46 @@ dashedName: match-literal-strings
|
|||||||
|
|
||||||
# --description--
|
# --description--
|
||||||
|
|
||||||
In the last challenge, you searched for the word `"Hello"` using the regular expression `/Hello/`. That regex searched for a literal match of the string `"Hello"`. Here's another example searching for a literal match of the string `"Kevin"`:
|
En el desafío anterior, buscaste la palabra `Hello` usando la expresión regular `/Hello/`. Esa expresión regular buscó una coincidencia literal de la cadena `Hello`. Aquí hay otro ejemplo donde se busca una coincidencia literal de la cadena `Kevin`:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
let testStr = "Hello, my name is Kevin.";
|
let testStr = "Hello, my name is Kevin.";
|
||||||
let testRegex = /Kevin/;
|
let testRegex = /Kevin/;
|
||||||
testRegex.test(testStr);
|
testRegex.test(testStr);
|
||||||
// Returns true
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Any other forms of `"Kevin"` will not match. For example, the regex `/Kevin/` will not match `"kevin"` or `"KEVIN"`.
|
Esta llamada a `test` devolverá `true`.
|
||||||
|
|
||||||
|
Cualquier otra variante de `Kevin` no coincidirá. Por ejemplo, la expresión regular `/Kevin/` no coincidirá con `kevin` o `KEVIN`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
let wrongRegex = /kevin/;
|
let wrongRegex = /kevin/;
|
||||||
wrongRegex.test(testStr);
|
wrongRegex.test(testStr);
|
||||||
// Returns false
|
|
||||||
```
|
```
|
||||||
|
|
||||||
A future challenge will show how to match those other forms as well.
|
Esta llamada a `test` devolverá `false`.
|
||||||
|
|
||||||
|
Un futuro desafío también mostrará cómo coincidir esas otras variantes.
|
||||||
|
|
||||||
# --instructions--
|
# --instructions--
|
||||||
|
|
||||||
Complete the regex `waldoRegex` to find `"Waldo"` in the string `waldoIsHiding` with a literal match.
|
Completa la expresión regular `waldoRegex` para encontrar `"Waldo"` en la cadena `waldoIsHiding` con una coincidencia literal.
|
||||||
|
|
||||||
# --hints--
|
# --hints--
|
||||||
|
|
||||||
Your regex `waldoRegex` should find `"Waldo"`
|
Tu expresión regular `waldoRegex` debe encontrar la cadena `Waldo`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(waldoRegex.test(waldoIsHiding));
|
assert(waldoRegex.test(waldoIsHiding));
|
||||||
```
|
```
|
||||||
|
|
||||||
Your regex `waldoRegex` should not search for anything else.
|
Tu expresión regular `waldoRegex` no debe buscar ninguna otra cosa.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(!waldoRegex.test('Somewhere is hiding in this text.'));
|
assert(!waldoRegex.test('Somewhere is hiding in this text.'));
|
||||||
```
|
```
|
||||||
|
|
||||||
You should perform a literal string match with your regex.
|
Debes realizar una coincidencia de cadena literal con tu expresión regular.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(!/\/.*\/i/.test(code));
|
assert(!/\/.*\/i/.test(code));
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
id: 587d7db9367417b2b2512ba4
|
id: 587d7db9367417b2b2512ba4
|
||||||
title: Match Non-Whitespace Characters
|
title: Haz coincidir caracteres que no sean espacios en blanco
|
||||||
challengeType: 1
|
challengeType: 1
|
||||||
forumTopicId: 18210
|
forumTopicId: 18210
|
||||||
dashedName: match-non-whitespace-characters
|
dashedName: match-non-whitespace-characters
|
||||||
@ -8,35 +8,37 @@ dashedName: match-non-whitespace-characters
|
|||||||
|
|
||||||
# --description--
|
# --description--
|
||||||
|
|
||||||
You learned about searching for whitespace using `\s`, with a lowercase `s`. You can also search for everything except whitespace.
|
Aprendiste a buscar espacios en blanco usando `\s`, con una `s` en minúscula. También puedes buscar todo excepto los espacios en blanco.
|
||||||
|
|
||||||
Search for non-whitespace using `\S`, which is an uppercase `s`. This pattern will not match whitespace, carriage return, tab, form feed, and new line characters. You can think of it being similar to the character class `[^ \r\t\f\n\v]`.
|
Busca caracteres que no sean espacios en blanco usando `\S`, la cual es una `s` mayúscula. Este patrón no coincidirá con los caracteres de espacios en blanco, retorno de carro, tabulaciones, alimentación de formulario y saltos de línea. Puedes pensar que es similar a la clase de caracteres `[^ \r\t\f\n\v]`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
let whiteSpace = "Whitespace. Whitespace everywhere!"
|
let whiteSpace = "Whitespace. Whitespace everywhere!"
|
||||||
let nonSpaceRegex = /\S/g;
|
let nonSpaceRegex = /\S/g;
|
||||||
whiteSpace.match(nonSpaceRegex).length; // Returns 32
|
whiteSpace.match(nonSpaceRegex).length;
|
||||||
```
|
```
|
||||||
|
|
||||||
|
El valor devuelto por el método `.length` sería `32`.
|
||||||
|
|
||||||
# --instructions--
|
# --instructions--
|
||||||
|
|
||||||
Change the regex `countNonWhiteSpace` to look for multiple non-whitespace characters in a string.
|
Cambia la expresión regular `countNonWhiteSpace` para buscar varios caracteres que no sean espacios en blanco en una cadena.
|
||||||
|
|
||||||
# --hints--
|
# --hints--
|
||||||
|
|
||||||
Your regex should use the global flag.
|
Tu expresión regular debe usar la bandera global.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(countNonWhiteSpace.global);
|
assert(countNonWhiteSpace.global);
|
||||||
```
|
```
|
||||||
|
|
||||||
Your regex should use the shorthand character `\S` to match all non-whitespace characters.
|
Tu expresión regular debe usar el carácter abreviado `\S` para que coincida con todos los caracteres que no sean espacios en blanco.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(/\\S/.test(countNonWhiteSpace.source));
|
assert(/\\S/.test(countNonWhiteSpace.source));
|
||||||
```
|
```
|
||||||
|
|
||||||
Your regex should find 35 non-spaces in `"Men are from Mars and women are from Venus."`
|
Tu expresión regular debe encontrar 35 caracteres que no sean espacios en la cadena `Men are from Mars and women are from Venus.`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(
|
assert(
|
||||||
@ -45,13 +47,13 @@ assert(
|
|||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
Your regex should find 23 non-spaces in `"Space: the final frontier."`
|
Tu expresión regular debe encontrar 23 caracteres que no sean espacios en la cadena `Space: the final frontier.`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert('Space: the final frontier.'.match(countNonWhiteSpace).length == 23);
|
assert('Space: the final frontier.'.match(countNonWhiteSpace).length == 23);
|
||||||
```
|
```
|
||||||
|
|
||||||
Your regex should find 21 non-spaces in `"MindYourPersonalSpace"`
|
Tu expresión regular debe encontrar 21 caracteres que no sean espacios en la cadena `MindYourPersonalSpace`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert('MindYourPersonalSpace'.match(countNonWhiteSpace).length == 21);
|
assert('MindYourPersonalSpace'.match(countNonWhiteSpace).length == 21);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
id: 587d7db5367417b2b2512b97
|
id: 587d7db5367417b2b2512b97
|
||||||
title: Match Numbers and Letters of the Alphabet
|
title: Haz coincidir los números y las letras del alfabeto
|
||||||
challengeType: 1
|
challengeType: 1
|
||||||
forumTopicId: 301356
|
forumTopicId: 301356
|
||||||
dashedName: match-numbers-and-letters-of-the-alphabet
|
dashedName: match-numbers-and-letters-of-the-alphabet
|
||||||
@ -8,38 +8,37 @@ dashedName: match-numbers-and-letters-of-the-alphabet
|
|||||||
|
|
||||||
# --description--
|
# --description--
|
||||||
|
|
||||||
Using the hyphen (`-`) to match a range of characters is not limited to letters. It also works to match a range of numbers.
|
Usar el guión (`-`) para coincidir con un rango de caracteres no está limitado a letras. También funciona para hacer coincidir un rango de números.
|
||||||
|
|
||||||
For example, `/[0-5]/` matches any number between `0` and `5`, including the `0` and `5`.
|
Por ejemplo, `/[0-5]/` coincide con cualquier número entre `0` y `5`, incluyendo `0` y `5`.
|
||||||
|
|
||||||
Also, it is possible to combine a range of letters and numbers in a single character set.
|
Además, es posible combinar un rango de letras y números en un único conjunto de caracteres.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
let jennyStr = "Jenny8675309";
|
let jennyStr = "Jenny8675309";
|
||||||
let myRegex = /[a-z0-9]/ig;
|
let myRegex = /[a-z0-9]/ig;
|
||||||
// matches all letters and numbers in jennyStr
|
|
||||||
jennyStr.match(myRegex);
|
jennyStr.match(myRegex);
|
||||||
```
|
```
|
||||||
|
|
||||||
# --instructions--
|
# --instructions--
|
||||||
|
|
||||||
Create a single regex that matches a range of letters between `h` and `s`, and a range of numbers between `2` and `6`. Remember to include the appropriate flags in the regex.
|
Crea una sola expresión regular que coincida con un rango de letras entre `h` y `s`, y un rango de números entre `2` y `6`. Recuerda incluir las banderas apropiadas en la expresión regular.
|
||||||
|
|
||||||
# --hints--
|
# --hints--
|
||||||
|
|
||||||
Your regex `myRegex` should match 17 items.
|
Tu expresión regular `myRegex` debe coincidir con 17 elementos.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(result.length == 17);
|
assert(result.length == 17);
|
||||||
```
|
```
|
||||||
|
|
||||||
Your regex `myRegex` should use the global flag.
|
Tu expresión regular `myRegex` debe utilizar la bandera global.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(myRegex.flags.match(/g/).length == 1);
|
assert(myRegex.flags.match(/g/).length == 1);
|
||||||
```
|
```
|
||||||
|
|
||||||
Your regex `myRegex` should use the case insensitive flag.
|
Tu expresión regular `myRegex` debe utilizar la bandera que no distingue entre mayúsculas y minúsculas.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(myRegex.flags.match(/i/).length == 1);
|
assert(myRegex.flags.match(/i/).length == 1);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
id: 587d7dba367417b2b2512ba9
|
id: 587d7dba367417b2b2512ba9
|
||||||
title: Positive and Negative Lookahead
|
title: Lookahead positivo y negativo
|
||||||
challengeType: 1
|
challengeType: 1
|
||||||
forumTopicId: 301360
|
forumTopicId: 301360
|
||||||
dashedName: positive-and-negative-lookahead
|
dashedName: positive-and-negative-lookahead
|
||||||
@ -8,88 +8,90 @@ dashedName: positive-and-negative-lookahead
|
|||||||
|
|
||||||
# --description--
|
# --description--
|
||||||
|
|
||||||
<dfn>Lookaheads</dfn> are patterns that tell JavaScript to look-ahead in your string to check for patterns further along. This can be useful when you want to search for multiple patterns over the same string.
|
Los <dfn>lookaheads</dfn> son patrones que le indican a JavaScript que busque por anticipado en tu cadena para verificar patrones más adelante. Esto puede ser útil cuando deseas buscar varios patrones sobre la misma cadena.
|
||||||
|
|
||||||
There are two kinds of lookaheads: <dfn>positive lookahead</dfn> and <dfn>negative lookahead</dfn>.
|
Hay dos tipos de lookaheads: <dfn>lookahead positivo</dfn> y <dfn>lookahead negativo</dfn>.
|
||||||
|
|
||||||
A positive lookahead will look to make sure the element in the search pattern is there, but won't actually match it. A positive lookahead is used as `(?=...)` where the `...` is the required part that is not matched.
|
Un lookahead positivo buscará para asegurarse de que el elemento en el patrón de búsqueda este allí, pero en realidad no lo coincidirá. Un lookahead positivo se usa como `(?=...)` donde el `...` es la parte requerida que no coincide.
|
||||||
|
|
||||||
On the other hand, a negative lookahead will look to make sure the element in the search pattern is not there. A negative lookahead is used as `(?!...)` where the `...` is the pattern that you do not want to be there. The rest of the pattern is returned if the negative lookahead part is not present.
|
Por otro lado, un lookahead negativo buscará para asegurarse de que el elemento en el patrón de búsqueda no este allí. Un lookahead negativo se usa como `(?!...)` donde el `...` es el patrón que no quieres que esté allí. El resto del patrón se devuelve si la parte de lookahead negativo no está presente.
|
||||||
|
|
||||||
Lookaheads are a bit confusing but some examples will help.
|
Los lookaheads son un poco confusos, pero algunos ejemplos ayudarán.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
let quit = "qu";
|
let quit = "qu";
|
||||||
let noquit = "qt";
|
let noquit = "qt";
|
||||||
let quRegex= /q(?=u)/;
|
let quRegex= /q(?=u)/;
|
||||||
let qRegex = /q(?!u)/;
|
let qRegex = /q(?!u)/;
|
||||||
quit.match(quRegex); // Returns ["q"]
|
quit.match(quRegex);
|
||||||
noquit.match(qRegex); // Returns ["q"]
|
noquit.match(qRegex);
|
||||||
```
|
```
|
||||||
|
|
||||||
A more practical use of lookaheads is to check two or more patterns in one string. Here is a (naively) simple password checker that looks for between 3 and 6 characters and at least one number:
|
Ambas llamadas a `match` devolverán `["q"]`.
|
||||||
|
|
||||||
|
Un uso más práctico de lookaheads es comprobar dos o más patrones en una cadena. Aquí hay un verificador de contraseñas (ingenuamente) simple que busca entre 3 y 6 caracteres y al menos un número:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
let password = "abc123";
|
let password = "abc123";
|
||||||
let checkPass = /(?=\w{3,6})(?=\D*\d)/;
|
let checkPass = /(?=\w{3,6})(?=\D*\d)/;
|
||||||
checkPass.test(password); // Returns true
|
checkPass.test(password);
|
||||||
```
|
```
|
||||||
|
|
||||||
# --instructions--
|
# --instructions--
|
||||||
|
|
||||||
Use lookaheads in the `pwRegex` to match passwords that are greater than 5 characters long, and have two consecutive digits.
|
Utiliza los lookaheads en el `pwRegex` para que coincida con las contraseñas que tengan más de 5 caracteres y dos dígitos consecutivos.
|
||||||
|
|
||||||
# --hints--
|
# --hints--
|
||||||
|
|
||||||
Your regex should use two positive `lookaheads`.
|
Tu expresión regular debe usar dos `lookaheads` positivos.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(pwRegex.source.match(/\(\?=.*?\)\(\?=.*?\)/) !== null);
|
assert(pwRegex.source.match(/\(\?=.*?\)\(\?=.*?\)/) !== null);
|
||||||
```
|
```
|
||||||
|
|
||||||
Your regex should not match `"astronaut"`
|
Tu expresión regular no debe coincidir con la cadena `astronaut`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(!pwRegex.test('astronaut'));
|
assert(!pwRegex.test('astronaut'));
|
||||||
```
|
```
|
||||||
|
|
||||||
Your regex should not match `"banan1"`
|
Tu expresión regular no debe coincidir con la cadena `banan1`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(!pwRegex.test('banan1'));
|
assert(!pwRegex.test('banan1'));
|
||||||
```
|
```
|
||||||
|
|
||||||
Your regex should match `"bana12"`
|
Tu expresión regular debe coincidir con la cadena `bana12`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(pwRegex.test('bana12'));
|
assert(pwRegex.test('bana12'));
|
||||||
```
|
```
|
||||||
|
|
||||||
Your regex should match `"abc123"`
|
Tu expresión regular debe coincidir con la cadena `abc123`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(pwRegex.test('abc123'));
|
assert(pwRegex.test('abc123'));
|
||||||
```
|
```
|
||||||
|
|
||||||
Your regex should not match `"12345"`
|
Tu expresión regular no debe coincidir con la cadena `12345`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(!pwRegex.test('12345'));
|
assert(!pwRegex.test('12345'));
|
||||||
```
|
```
|
||||||
|
|
||||||
Your regex should match `"8pass99"`
|
Tu expresión regular debe coincidir con la cadena `8pass99`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(pwRegex.test('8pass99'));
|
assert(pwRegex.test('8pass99'));
|
||||||
```
|
```
|
||||||
|
|
||||||
Your regex should not match `"1a2bcde"`
|
Tu expresión regular no debe coincidir con la cadena `1a2bcde`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(!pwRegex.test('1a2bcde'));
|
assert(!pwRegex.test('1a2bcde'));
|
||||||
```
|
```
|
||||||
|
|
||||||
Your regex should match `"astr1on11aut"`
|
Tu expresión regular debe coincidir con la cadena `astr1on11aut`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(pwRegex.test('astr1on11aut'));
|
assert(pwRegex.test('astr1on11aut'));
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
id: 587d7db8367417b2b2512ba2
|
id: 587d7db8367417b2b2512ba2
|
||||||
title: Restrict Possible Usernames
|
title: Restringe posibles nombres de usuario
|
||||||
challengeType: 1
|
challengeType: 1
|
||||||
forumTopicId: 301363
|
forumTopicId: 301363
|
||||||
dashedName: restrict-possible-usernames
|
dashedName: restrict-possible-usernames
|
||||||
@ -8,96 +8,102 @@ dashedName: restrict-possible-usernames
|
|||||||
|
|
||||||
# --description--
|
# --description--
|
||||||
|
|
||||||
Usernames are used everywhere on the internet. They are what give users a unique identity on their favorite sites.
|
Los nombres de usuario se utilizan en todas partes en Internet. Son los que dan a los usuarios una identidad única en tus sitios favoritos.
|
||||||
|
|
||||||
You need to check all the usernames in a database. Here are some simple rules that users have to follow when creating their username.
|
Se necesita comprobar todos los nombres de usuario en una base de datos. Estas son algunas reglas simples que los usuarios deben seguir al crear su nombre de usuario.
|
||||||
|
|
||||||
1) Usernames can only use alpha-numeric characters.
|
1) Los nombres de usuario sólo pueden utilizar caracteres alfanuméricos.
|
||||||
|
|
||||||
2) The only numbers in the username have to be at the end. There can be zero or more of them at the end. Username cannot start with the number.
|
2) Los únicos números del nombre de usuario tienen que estar al final. Puede tener un cero o más al final. El nombre de usuario no puede iniciar con un número.
|
||||||
|
|
||||||
3) Username letters can be lowercase and uppercase.
|
3) Las letras del nombre de usuario pueden ser minúsculas y mayúsculas.
|
||||||
|
|
||||||
4) Usernames have to be at least two characters long. A two-character username can only use alphabet letters as characters.
|
4) Los nombres de usuario deben tener al menos dos caracteres. Un nombre de usuario de dos caracteres sólo puede utilizar letras del alfabeto como caracteres.
|
||||||
|
|
||||||
# --instructions--
|
# --instructions--
|
||||||
|
|
||||||
Change the regex `userCheck` to fit the constraints listed above.
|
Cambia la expresión regular `userCheck` para que se ajuste a las restricciones indicadas anteriormente.
|
||||||
|
|
||||||
# --hints--
|
# --hints--
|
||||||
|
|
||||||
Your regex should match `JACK`
|
Tu expresión regular debe coincidir con la cadena `JACK`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(userCheck.test('JACK'));
|
assert(userCheck.test('JACK'));
|
||||||
```
|
```
|
||||||
|
|
||||||
Your regex should not match `J`
|
Tu expresión regular no debe coincidir con la cadena `J`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(!userCheck.test('J'));
|
assert(!userCheck.test('J'));
|
||||||
```
|
```
|
||||||
|
|
||||||
Your regex should match `Jo`
|
Tu expresión regular debe coincidir con la cadena `Jo`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(userCheck.test('Jo'));
|
assert(userCheck.test('Jo'));
|
||||||
```
|
```
|
||||||
|
|
||||||
Your regex should match `Oceans11`
|
Tu expresión regular debe coincidir con la cadena `Oceans11`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(userCheck.test('Oceans11'));
|
assert(userCheck.test('Oceans11'));
|
||||||
```
|
```
|
||||||
|
|
||||||
Your regex should match `RegexGuru`
|
Tu expresión regular debe coincidir con la cadena `RegexGuru`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(userCheck.test('RegexGuru'));
|
assert(userCheck.test('RegexGuru'));
|
||||||
```
|
```
|
||||||
|
|
||||||
Your regex should not match `007`
|
Tu expresión regular no debe coincidir con la cadena `007`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(!userCheck.test('007'));
|
assert(!userCheck.test('007'));
|
||||||
```
|
```
|
||||||
|
|
||||||
Your regex should not match `9`
|
Tu expresión regular no debe coincidir con la cadena `9`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(!userCheck.test('9'));
|
assert(!userCheck.test('9'));
|
||||||
```
|
```
|
||||||
|
|
||||||
Your regex should not match `A1`
|
Tu expresión regular no debe coincidir con la cadena `A1`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(!userCheck.test('A1'));
|
assert(!userCheck.test('A1'));
|
||||||
```
|
```
|
||||||
|
|
||||||
Your regex should not match `BadUs3rnam3`
|
Tu expresión regular no debe coincidir con la cadena `BadUs3rnam3`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(!userCheck.test('BadUs3rnam3'));
|
assert(!userCheck.test('BadUs3rnam3'));
|
||||||
```
|
```
|
||||||
|
|
||||||
Your regex should match `Z97`
|
Tu expresión regular debe coincidir con la cadena `Z97`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(userCheck.test('Z97'));
|
assert(userCheck.test('Z97'));
|
||||||
```
|
```
|
||||||
|
|
||||||
Your regex should not match `c57bT3`
|
Tu expresión regular no debe coincidir con la cadena `c57bT3`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(!userCheck.test('c57bT3'));
|
assert(!userCheck.test('c57bT3'));
|
||||||
```
|
```
|
||||||
|
|
||||||
Your regex should match `AB1`
|
Tu expresión regular debe coincidir con la cadena `AB1`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(userCheck.test('AB1'));
|
assert(userCheck.test('AB1'));
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Tu expresión regular no debe coincidir con la cadena `J%4`
|
||||||
|
|
||||||
|
```js
|
||||||
|
assert(!userCheck.test('J%4'))
|
||||||
|
```
|
||||||
|
|
||||||
# --seed--
|
# --seed--
|
||||||
|
|
||||||
## --seed-contents--
|
## --seed-contents--
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
id: 587d7dbb367417b2b2512baa
|
id: 587d7dbb367417b2b2512baa
|
||||||
title: Reuse Patterns Using Capture Groups
|
title: Reutiliza patrones usando grupos de captura
|
||||||
challengeType: 1
|
challengeType: 1
|
||||||
forumTopicId: 301364
|
forumTopicId: 301364
|
||||||
dashedName: reuse-patterns-using-capture-groups
|
dashedName: reuse-patterns-using-capture-groups
|
||||||
@ -8,78 +8,80 @@ dashedName: reuse-patterns-using-capture-groups
|
|||||||
|
|
||||||
# --description--
|
# --description--
|
||||||
|
|
||||||
Some patterns you search for will occur multiple times in a string. It is wasteful to manually repeat that regex. There is a better way to specify when you have multiple repeat substrings in your string.
|
Algunos patrones que busques aparecerán múltiples veces en una cadena. Es un desperdicio repetir manualmente esa expresión regular. Existe una mejor forma de especificar que tienes múltiples subcadenas repetidas en tu cadena.
|
||||||
|
|
||||||
You can search for repeat substrings using <dfn>capture groups</dfn>. Parentheses, `(` and `)`, are used to find repeat substrings. You put the regex of the pattern that will repeat in between the parentheses.
|
Puedes buscar subcadenas repetidas utilizando <dfn>grupos de captura</dfn>. Los paréntesis, `(` y `)`, son usados para encontrar subcadenas repetidas. Introduces la expresión regular del patrón que se repetirá entre los paréntesis.
|
||||||
|
|
||||||
To specify where that repeat string will appear, you use a backslash (<code>\\</code>) and then a number. This number starts at 1 and increases with each additional capture group you use. An example would be `\1` to match the first group.
|
Para especificar donde aparecerá esa cadena repetida, utilizarás una barra invertida (`\`) y luego un número. Este número inicia en 1 e incrementa con cada grupo de captura adicional que utilices. Un ejemplo podría ser `\1` para coincidir con el primer grupo.
|
||||||
|
|
||||||
The example below matches any word that occurs twice separated by a space:
|
El siguiente ejemplo encuentra cualquier palabra que ocurra dos veces separada por un espacio:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
let repeatStr = "regex regex";
|
let repeatStr = "regex regex";
|
||||||
let repeatRegex = /(\w+)\s\1/;
|
let repeatRegex = /(\w+)\s\1/;
|
||||||
repeatRegex.test(repeatStr); // Returns true
|
repeatRegex.test(repeatStr);
|
||||||
repeatStr.match(repeatRegex); // Returns ["regex regex", "regex"]
|
repeatStr.match(repeatRegex);
|
||||||
```
|
```
|
||||||
|
|
||||||
Using the `.match()` method on a string will return an array with the string it matches, along with its capture group.
|
La llamada a la función `test` devolverá `true`, y la llamada a la función `match` devolverá `["regex regex", "regex"]`.
|
||||||
|
|
||||||
|
Utilizar el método `.match()` en una cadena devuelve un arreglo con la cadena que coincide, junto con su grupo de captura.
|
||||||
|
|
||||||
# --instructions--
|
# --instructions--
|
||||||
|
|
||||||
Use capture groups in `reRegex` to match a string that consists of only the same number repeated exactly three times separated by single spaces.
|
Utiliza los grupos de captura en `reRegex` para que coincida con una cadena que conste sólo del mismo número repetido exactamente tres veces separado por espacios.
|
||||||
|
|
||||||
# --hints--
|
# --hints--
|
||||||
|
|
||||||
Your regex should use the shorthand character class for digits.
|
Tu expresión regular debe utilizar la clase de caracteres abreviada para los dígitos.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(reRegex.source.match(/\\d/));
|
assert(reRegex.source.match(/\\d/));
|
||||||
```
|
```
|
||||||
|
|
||||||
Your regex should reuse a capture group twice.
|
Tu expresión regular debe reutilizar un grupo de captura dos veces.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(reRegex.source.match(/\\1|\\2/g).length >= 2);
|
assert(reRegex.source.match(/\\1|\\2/g).length >= 2);
|
||||||
```
|
```
|
||||||
|
|
||||||
Your regex should match `"42 42 42"`.
|
Tu expresión regular debe coincidir con la cadena `42 42 42`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(reRegex.test('42 42 42'));
|
assert(reRegex.test('42 42 42'));
|
||||||
```
|
```
|
||||||
|
|
||||||
Your regex should match `"100 100 100"`.
|
Tu expresión regular debe coincidir con la cadena `100 100 100`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(reRegex.test('100 100 100'));
|
assert(reRegex.test('100 100 100'));
|
||||||
```
|
```
|
||||||
|
|
||||||
Your regex should not match `"42 42 42 42"`.
|
Tu expresión regular no debe coincidir con la cadena `42 42 42 42`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.equal('42 42 42 42'.match(reRegex.source), null);
|
assert.equal('42 42 42 42'.match(reRegex.source), null);
|
||||||
```
|
```
|
||||||
|
|
||||||
Your regex should not match `"42 42"`.
|
Tu expresión regular no debe coincidir con la cadena `42 42`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.equal('42 42'.match(reRegex.source), null);
|
assert.equal('42 42'.match(reRegex.source), null);
|
||||||
```
|
```
|
||||||
|
|
||||||
Your regex should not match `"101 102 103"`.
|
Tu expresión regular no debe coincidir con la cadena `101 102 103`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(!reRegex.test('101 102 103'));
|
assert(!reRegex.test('101 102 103'));
|
||||||
```
|
```
|
||||||
|
|
||||||
Your regex should not match `"1 2 3"`.
|
Tu expresión regular no debe coincidir con la cadena `1 2 3`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(!reRegex.test('1 2 3'));
|
assert(!reRegex.test('1 2 3'));
|
||||||
```
|
```
|
||||||
|
|
||||||
Your regex should match `"10 10 10"`.
|
Tu expresión regular debe coincidir con la cadena `10 10 10`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(reRegex.test('10 10 10'));
|
assert(reRegex.test('10 10 10'));
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
id: 587d7db9367417b2b2512ba6
|
id: 587d7db9367417b2b2512ba6
|
||||||
title: Specify Only the Lower Number of Matches
|
title: Especifica solo el menor número de coincidencias
|
||||||
challengeType: 1
|
challengeType: 1
|
||||||
forumTopicId: 301366
|
forumTopicId: 301366
|
||||||
dashedName: specify-only-the-lower-number-of-matches
|
dashedName: specify-only-the-lower-number-of-matches
|
||||||
@ -8,65 +8,67 @@ dashedName: specify-only-the-lower-number-of-matches
|
|||||||
|
|
||||||
# --description--
|
# --description--
|
||||||
|
|
||||||
You can specify the lower and upper number of patterns with quantity specifiers using curly brackets. Sometimes you only want to specify the lower number of patterns with no upper limit.
|
Puedes especificar el número inferior y superior de patrones mediante especificadores de cantidad utilizando llaves. A veces sólo se quiere especificar el número inferior de patrones sin tener un límite superior.
|
||||||
|
|
||||||
To only specify the lower number of patterns, keep the first number followed by a comma.
|
Para especificar sólo el número inferior de patrones, mantén el primer número seguido de una coma.
|
||||||
|
|
||||||
For example, to match only the string `"hah"` with the letter `a` appearing at least `3` times, your regex would be `/ha{3,}h/`.
|
Por ejemplo, para hacer coincidir solo con la cadena `hah` cuando la letra `a` aparezca al menos `3` veces, la expresión regular sería `/ha{3,}h/`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
let A4 = "haaaah";
|
let A4 = "haaaah";
|
||||||
let A2 = "haah";
|
let A2 = "haah";
|
||||||
let A100 = "h" + "a".repeat(100) + "h";
|
let A100 = "h" + "a".repeat(100) + "h";
|
||||||
let multipleA = /ha{3,}h/;
|
let multipleA = /ha{3,}h/;
|
||||||
multipleA.test(A4); // Returns true
|
multipleA.test(A4);
|
||||||
multipleA.test(A2); // Returns false
|
multipleA.test(A2);
|
||||||
multipleA.test(A100); // Returns true
|
multipleA.test(A100);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
En orden, las tres llamadas a `test` devuelven `true`, `false` y `true`.
|
||||||
|
|
||||||
# --instructions--
|
# --instructions--
|
||||||
|
|
||||||
Change the regex `haRegex` to match the word `"Hazzah"` only when it has four or more letter `z`'s.
|
Modifica la expresión regular `haRegex` para coincidir con la palabra `Hazzah` solo cuando ésta tiene cuatro o más letras `z`.
|
||||||
|
|
||||||
# --hints--
|
# --hints--
|
||||||
|
|
||||||
Your regex should use curly brackets.
|
La expresión regular debe utilizar llaves.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(haRegex.source.match(/{.*?}/).length > 0);
|
assert(haRegex.source.match(/{.*?}/).length > 0);
|
||||||
```
|
```
|
||||||
|
|
||||||
Your regex should not match `"Hazzah"`
|
La expresión regular no debe coincidir con la cadena `Hazzah`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(!haRegex.test('Hazzah'));
|
assert(!haRegex.test('Hazzah'));
|
||||||
```
|
```
|
||||||
|
|
||||||
Your regex should not match `"Hazzzah"`
|
La expresión regular no debe coincidir con la cadena `Hazzzah`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(!haRegex.test('Hazzzah'));
|
assert(!haRegex.test('Hazzzah'));
|
||||||
```
|
```
|
||||||
|
|
||||||
Your regex should match `"Hazzzzah"`
|
La expresión regular debe coincidir con la cadena `Hazzzzah`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert('Hazzzzah'.match(haRegex)[0].length === 8);
|
assert('Hazzzzah'.match(haRegex)[0].length === 8);
|
||||||
```
|
```
|
||||||
|
|
||||||
Your regex should match `"Hazzzzzah"`
|
La expresión regular debe coincidir con la cadena `Hazzzzzah`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert('Hazzzzzah'.match(haRegex)[0].length === 9);
|
assert('Hazzzzzah'.match(haRegex)[0].length === 9);
|
||||||
```
|
```
|
||||||
|
|
||||||
Your regex should match `"Hazzzzzzah"`
|
La expresión regular debe coincidir con la cadena `Hazzzzzzah`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert('Hazzzzzzah'.match(haRegex)[0].length === 10);
|
assert('Hazzzzzzah'.match(haRegex)[0].length === 10);
|
||||||
```
|
```
|
||||||
|
|
||||||
Your regex should match `"Hazzah"` with 30 `z`'s in it.
|
La expresión regular debe coincidir con la cadena `Hazzah` con 30 `z`'s.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert('Hazzzzzzzzzzzzzzzzzzzzzzzzzzzzzzah'.match(haRegex)[0].length === 34);
|
assert('Hazzzzzzzzzzzzzzzzzzzzzzzzzzzzzzah'.match(haRegex)[0].length === 34);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
id: 587d7db9367417b2b2512ba5
|
id: 587d7db9367417b2b2512ba5
|
||||||
title: Specify Upper and Lower Number of Matches
|
title: Especifica el menor y mayor número de coincidencias
|
||||||
challengeType: 1
|
challengeType: 1
|
||||||
forumTopicId: 301367
|
forumTopicId: 301367
|
||||||
dashedName: specify-upper-and-lower-number-of-matches
|
dashedName: specify-upper-and-lower-number-of-matches
|
||||||
@ -8,63 +8,65 @@ dashedName: specify-upper-and-lower-number-of-matches
|
|||||||
|
|
||||||
# --description--
|
# --description--
|
||||||
|
|
||||||
Recall that you use the plus sign `+` to look for one or more characters and the asterisk `*` to look for zero or more characters. These are convenient but sometimes you want to match a certain range of patterns.
|
Recuerda que se utiliza el signo más `+` para buscar uno o más caracteres y el asterisco `*` para buscar cero o más caracteres. Esto es conveniente, pero a veces quieres coincidir con cierta gama de patrones.
|
||||||
|
|
||||||
You can specify the lower and upper number of patterns with <dfn>quantity specifiers</dfn>. Quantity specifiers are used with curly brackets (`{` and `}`). You put two numbers between the curly brackets - for the lower and upper number of patterns.
|
Puedes especificar el número inferior y superior de patrones utilizando <dfn>especificadores de cantidad</dfn>. Para los especificadores de cantidad utilizamos llaves (`{` y `}`). Pon dos números entre las llaves - para el número inferior y superior de patrones.
|
||||||
|
|
||||||
For example, to match only the letter `a` appearing between `3` and `5` times in the string `"ah"`, your regex would be `/a{3,5}h/`.
|
Por ejemplo, para que coincida con la letra `a` si aparece entre `3` y `5` veces en la cadena `ah`, la expresión regular debe ser `/a{3,5}h/`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
let A4 = "aaaah";
|
let A4 = "aaaah";
|
||||||
let A2 = "aah";
|
let A2 = "aah";
|
||||||
let multipleA = /a{3,5}h/;
|
let multipleA = /a{3,5}h/;
|
||||||
multipleA.test(A4); // Returns true
|
multipleA.test(A4);
|
||||||
multipleA.test(A2); // Returns false
|
multipleA.test(A2);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
La primera llamada a `test` devuelve `true`, mientras que la segunda devuelve `false`.
|
||||||
|
|
||||||
# --instructions--
|
# --instructions--
|
||||||
|
|
||||||
Change the regex `ohRegex` to match the entire phrase `"Oh no"` only when it has `3` to `6` letter `h`'s.
|
Modifica la expresión regular `ohRegex` para que coincida con toda la frase `Oh no` solo cuando tenga de `3` a `6` letras `h`.
|
||||||
|
|
||||||
# --hints--
|
# --hints--
|
||||||
|
|
||||||
Your regex should use curly brackets.
|
La expresión regular debe utilizar llaves.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(ohRegex.source.match(/{.*?}/).length > 0);
|
assert(ohRegex.source.match(/{.*?}/).length > 0);
|
||||||
```
|
```
|
||||||
|
|
||||||
Your regex should not match `"Ohh no"`
|
La expresión regular no debe coincidir con la cadena `Ohh no`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(!ohRegex.test('Ohh no'));
|
assert(!ohRegex.test('Ohh no'));
|
||||||
```
|
```
|
||||||
|
|
||||||
Your regex should match `"Ohhh no"`
|
La expresión regular debe coincidir con la cadena `Ohhh no`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert('Ohhh no'.match(ohRegex)[0].length === 7);
|
assert('Ohhh no'.match(ohRegex)[0].length === 7);
|
||||||
```
|
```
|
||||||
|
|
||||||
Your regex should match `"Ohhhh no"`
|
La expresión regular no debe coincidir con la cadena `Ohhhh no`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert('Ohhhh no'.match(ohRegex)[0].length === 8);
|
assert('Ohhhh no'.match(ohRegex)[0].length === 8);
|
||||||
```
|
```
|
||||||
|
|
||||||
Your regex should match `"Ohhhhh no"`
|
La expresión regular debe coincidir con la cadena `Ohhhhh no`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert('Ohhhhh no'.match(ohRegex)[0].length === 9);
|
assert('Ohhhhh no'.match(ohRegex)[0].length === 9);
|
||||||
```
|
```
|
||||||
|
|
||||||
Your regex should match `"Ohhhhhh no"`
|
La expresión regular debe coincidir con la cadena `Ohhhhhh no`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert('Ohhhhhh no'.match(ohRegex)[0].length === 10);
|
assert('Ohhhhhh no'.match(ohRegex)[0].length === 10);
|
||||||
```
|
```
|
||||||
|
|
||||||
Your regex should not match `"Ohhhhhhh no"`
|
La expresión regular no debe coincidir con la cadena `Ohhhhhhh no`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(!ohRegex.test('Ohhhhhhh no'));
|
assert(!ohRegex.test('Ohhhhhhh no'));
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
id: 587d7dbb367417b2b2512bab
|
id: 587d7dbb367417b2b2512bab
|
||||||
title: Use Capture Groups to Search and Replace
|
title: Usa grupos de captura para buscar y reemplazar
|
||||||
challengeType: 1
|
challengeType: 1
|
||||||
forumTopicId: 301368
|
forumTopicId: 301368
|
||||||
dashedName: use-capture-groups-to-search-and-replace
|
dashedName: use-capture-groups-to-search-and-replace
|
||||||
@ -8,55 +8,57 @@ dashedName: use-capture-groups-to-search-and-replace
|
|||||||
|
|
||||||
# --description--
|
# --description--
|
||||||
|
|
||||||
Searching is useful. However, you can make searching even more powerful when it also changes (or replaces) the text you match.
|
La búsqueda es útil. Sin embargo, puedes hacer que la búsqueda sea aún más poderosa si también cambias (o reemplazas) el texto con el que coincide.
|
||||||
|
|
||||||
You can search and replace text in a string using `.replace()` on a string. The inputs for `.replace()` is first the regex pattern you want to search for. The second parameter is the string to replace the match or a function to do something.
|
Puedes buscar y reemplazar texto en una cadena usando `.replace()` en una cadena. Las entradas para `.replace()` son primero el patrón de expresiones regulares que deseas buscar. El segundo parámetro es la cadena para reemplazar la coincidencia o una función para hacer algo.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
let wrongText = "The sky is silver.";
|
let wrongText = "The sky is silver.";
|
||||||
let silverRegex = /silver/;
|
let silverRegex = /silver/;
|
||||||
wrongText.replace(silverRegex, "blue");
|
wrongText.replace(silverRegex, "blue");
|
||||||
// Returns "The sky is blue."
|
|
||||||
```
|
```
|
||||||
|
|
||||||
You can also access capture groups in the replacement string with dollar signs (`$`).
|
La llamada `replace` devolverá la cadena `The sky is blue.`.
|
||||||
|
|
||||||
|
También puedes acceder a grupos de captura en la cadena de reemplazo con signos de dólar. (`$`).
|
||||||
|
|
||||||
```js
|
```js
|
||||||
"Code Camp".replace(/(\w+)\s(\w+)/, '$2 $1');
|
"Code Camp".replace(/(\w+)\s(\w+)/, '$2 $1');
|
||||||
// Returns "Camp Code"
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
La llamada `replace` devolverá la cadena `Camp Code`.
|
||||||
|
|
||||||
# --instructions--
|
# --instructions--
|
||||||
|
|
||||||
Write a regex `fixRegex` using three capture groups that will search for each word in the string "one two three". Then update the `replaceText` variable to replace "one two three" with the string "three two one" and assign the result to the `result` variable. Make sure you are utilizing capture groups in the replacement string using the dollar sign (`$`) syntax.
|
Escribe una expresión regular `fixRegex` utilizando tres grupos de captura que buscarán cada palabra en la cadena `one two three`. Luego actualiza la variable `replaceText` para reemplazar `one two three` con la cadena `three two one` y asigna el resultado a la variable `result`. Asegúrate de utilizar grupos de captura en la cadena de reemplazo utilizando la sintaxis del signo de dólar (`$`).
|
||||||
|
|
||||||
# --hints--
|
# --hints--
|
||||||
|
|
||||||
You should use `.replace()` to search and replace.
|
Debes utilizar `.replace()` para buscar y reemplazar.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(code.match(/\.replace\(.*\)/));
|
assert(code.match(/\.replace\(.*\)/));
|
||||||
```
|
```
|
||||||
|
|
||||||
Your regex should change `"one two three"` to `"three two one"`
|
Tu expresión regular debe cambiar la cadena `one two three` a la cadena `three two one`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(result === 'three two one');
|
assert(result === 'three two one');
|
||||||
```
|
```
|
||||||
|
|
||||||
You should not change the last line.
|
No debes cambiar la última línea.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(code.match(/result\s*=\s*str\.replace\(.*?\)/));
|
assert(code.match(/result\s*=\s*str\.replace\(.*?\)/));
|
||||||
```
|
```
|
||||||
|
|
||||||
`fixRegex` should use at least three capture groups.
|
`fixRegex` debe usar al menos tres grupos de captura.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(new RegExp(fixRegex.source + '|').exec('').length - 1 >= 3);
|
assert(new RegExp(fixRegex.source + '|').exec('').length - 1 >= 3);
|
||||||
```
|
```
|
||||||
|
|
||||||
`replaceText` should use parenthesized submatch string(s) (i.e. the nth parenthesized submatch string, $n, corresponds to the nth capture group).
|
`replaceText` debe usar cadena(s) de subcoincidencia entre paréntesis (es decir, la enésima cadena de subcoincidencia entre parentesis, $n, corresponde al enésimo grupo de captura).
|
||||||
|
|
||||||
```js
|
```js
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
id: 587d7db3367417b2b2512b8e
|
id: 587d7db3367417b2b2512b8e
|
||||||
title: Using the Test Method
|
title: Usa el método "test"
|
||||||
challengeType: 1
|
challengeType: 1
|
||||||
forumTopicId: 301369
|
forumTopicId: 301369
|
||||||
dashedName: using-the-test-method
|
dashedName: using-the-test-method
|
||||||
@ -8,32 +8,33 @@ dashedName: using-the-test-method
|
|||||||
|
|
||||||
# --description--
|
# --description--
|
||||||
|
|
||||||
Regular expressions are used in programming languages to match parts of strings. You create patterns to help you do that matching.
|
Las expresiones regulares se utilizan en lenguajes de programación para coincidir con partes de cadenas. Creas patrones para ayudarte a hacer esa coincidencia.
|
||||||
|
|
||||||
If you want to find the word `"the"` in the string `"The dog chased the cat"`, you could use the following regular expression: `/the/`. Notice that quote marks are not required within the regular expression.
|
Si quieres encontrar la palabra `the` en la cadena `The dog chased the cat`, puedes utilizar la siguiente expresión regular: `/the/`. Ten en cuenta que las comillas no son requeridas dentro de la expresión regular.
|
||||||
|
|
||||||
JavaScript has multiple ways to use regexes. One way to test a regex is using the `.test()` method. The `.test()` method takes the regex, applies it to a string (which is placed inside the parentheses), and returns `true` or `false` if your pattern finds something or not.
|
JavaScript tiene múltiples formas de usar expresiones regulares. Una forma de probar una expresión regular es usando el método `.test()`. El método `.test()` toma la expresión regular, la aplica a una cadena (que se coloca dentro de los paréntesis), y devuelve `true` o `false` si tu patrón encuentra algo o no.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
let testStr = "freeCodeCamp";
|
let testStr = "freeCodeCamp";
|
||||||
let testRegex = /Code/;
|
let testRegex = /Code/;
|
||||||
testRegex.test(testStr);
|
testRegex.test(testStr);
|
||||||
// Returns true
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
El método `test` aquí devuelve `true`.
|
||||||
|
|
||||||
# --instructions--
|
# --instructions--
|
||||||
|
|
||||||
Apply the regex `myRegex` on the string `myString` using the `.test()` method.
|
Aplica la expresión regular `myRegex` en la cadena `myString` usando el método `.test()`.
|
||||||
|
|
||||||
# --hints--
|
# --hints--
|
||||||
|
|
||||||
You should use `.test()` to test the regex.
|
Debes usar `.test()` para probar la expresión regular.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(code.match(/myRegex.test\(\s*myString\s*\)/));
|
assert(code.match(/myRegex.test\(\s*myString\s*\)/));
|
||||||
```
|
```
|
||||||
|
|
||||||
Your result should return `true`.
|
Tu resultado debe devolver `true`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(result === true);
|
assert(result === true);
|
||||||
|
Reference in New Issue
Block a user