chore(i8n,curriculum): processed translations (#41560)
Co-authored-by: Crowdin Bot <support+bot@crowdin.com>
This commit is contained in:
@ -42,6 +42,7 @@ assert(
|
|||||||
## --seed-contents--
|
## --seed-contents--
|
||||||
|
|
||||||
```js
|
```js
|
||||||
|
|
||||||
// Only change code above this line
|
// Only change code above this line
|
||||||
|
|
||||||
stringFunctions.uppercaseString("hello");
|
stringFunctions.uppercaseString("hello");
|
||||||
|
@ -33,30 +33,36 @@ Puedes llamar o <dfn>invocar</dfn> esta función usando su nombre seguido por pa
|
|||||||
assert(typeof reusableFunction === 'function');
|
assert(typeof reusableFunction === 'function');
|
||||||
```
|
```
|
||||||
|
|
||||||
`reusableFunction` debe mostrar la cadena `Hi World` en la consola.
|
Si `reusableFunction` es llamado, este debe mostrar la cadena `Hi World` en la consola.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(hiWorldWasLogged);
|
assert(testConsole());
|
||||||
```
|
```
|
||||||
|
|
||||||
Debes llamar `reusableFunction` después de definirla.
|
Debes llamar `reusableFunction` después de definirla.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(/^\s*reusableFunction\(\)\s*/m.test(code));
|
const functionStr = reusableFunction && __helpers.removeWhiteSpace(reusableFunction.toString());
|
||||||
|
const codeWithoutFunction = __helpers.removeWhiteSpace(code).replace(/reusableFunction\(\)\{/g, '');
|
||||||
|
assert(/reusableFunction\(\)/.test(codeWithoutFunction));
|
||||||
```
|
```
|
||||||
|
|
||||||
# --seed--
|
# --seed--
|
||||||
|
|
||||||
## --before-user-code--
|
## --after-user-code--
|
||||||
|
|
||||||
```js
|
```js
|
||||||
var logOutput = "";
|
|
||||||
var originalConsole = console;
|
function testConsole() {
|
||||||
var nativeLog = console.log;
|
var logOutput = "";
|
||||||
var hiWorldWasLogged = false;
|
var originalConsole = console;
|
||||||
function capture() {
|
var nativeLog = console.log;
|
||||||
|
var hiWorldWasLogged = false;
|
||||||
console.log = function (message) {
|
console.log = function (message) {
|
||||||
if(message === 'Hi World') hiWorldWasLogged = true;
|
if(message === 'Hi World') {
|
||||||
|
console.warn(message)
|
||||||
|
hiWorldWasLogged = true;
|
||||||
|
}
|
||||||
if(message && message.trim) logOutput = message.trim();
|
if(message && message.trim) logOutput = message.trim();
|
||||||
if(nativeLog.apply) {
|
if(nativeLog.apply) {
|
||||||
nativeLog.apply(originalConsole, arguments);
|
nativeLog.apply(originalConsole, arguments);
|
||||||
@ -65,25 +71,11 @@ function capture() {
|
|||||||
nativeLog(nativeMsg);
|
nativeLog(nativeMsg);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
reusableFunction();
|
||||||
|
|
||||||
function uncapture() {
|
|
||||||
console.log = nativeLog;
|
console.log = nativeLog;
|
||||||
|
return hiWorldWasLogged;
|
||||||
}
|
}
|
||||||
|
|
||||||
capture();
|
|
||||||
```
|
|
||||||
|
|
||||||
## --after-user-code--
|
|
||||||
|
|
||||||
```js
|
|
||||||
uncapture();
|
|
||||||
|
|
||||||
if (typeof reusableFunction !== "function") {
|
|
||||||
(function() { return "reusableFunction is not defined"; })();
|
|
||||||
} else {
|
|
||||||
(function() { return logOutput || "console.log never called"; })();
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## --seed-contents--
|
## --seed-contents--
|
||||||
|
@ -42,6 +42,7 @@ assert(
|
|||||||
## --seed-contents--
|
## --seed-contents--
|
||||||
|
|
||||||
```js
|
```js
|
||||||
|
|
||||||
// Only change code above this line
|
// Only change code above this line
|
||||||
|
|
||||||
stringFunctions.uppercaseString("hello");
|
stringFunctions.uppercaseString("hello");
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
id: afd15382cdfb22c9efe8b7de
|
id: afd15382cdfb22c9efe8b7de
|
||||||
title: DNA Pairing
|
title: Emparejamiento de ADN
|
||||||
challengeType: 5
|
challengeType: 5
|
||||||
forumTopicId: 16009
|
forumTopicId: 16009
|
||||||
dashedName: dna-pairing
|
dashedName: dna-pairing
|
||||||
@ -8,19 +8,19 @@ dashedName: dna-pairing
|
|||||||
|
|
||||||
# --description--
|
# --description--
|
||||||
|
|
||||||
The DNA strand is missing the pairing element. Take each character, get its pair, and return the results as a 2d array.
|
A la cadena de ADN le falta el elemento de emparejamiento. Toma cada carácter, obtén su par y devuelve los resultados como un arreglo bidimensional.
|
||||||
|
|
||||||
[Base pairs](http://en.wikipedia.org/wiki/Base_pair) are a pair of AT and CG. Match the missing element to the provided character.
|
[Par de bases](https://es.wikipedia.org/wiki/Par_de_bases) son un par de AT y CG. Haz coincidir el elemento que falta con el carácter proporcionado.
|
||||||
|
|
||||||
Return the provided character as the first element in each array.
|
Devuelve el carácter proporcionado como primer elemento de cada arreglo.
|
||||||
|
|
||||||
For example, for the input GCG, return \[\["G", "C"], \["C","G"],\["G", "C"]]
|
Por ejemplo, la entrada `GCG`, devolverá `[["G", "C"], ["C","G"], ["G", "C"]]`
|
||||||
|
|
||||||
The character and its pair are paired up in an array, and all the arrays are grouped into one encapsulating array.
|
El carácter y su par se emparejan en un arreglo, y todos los arreglos se agrupan en un arreglo encapsulado.
|
||||||
|
|
||||||
# --hints--
|
# --hints--
|
||||||
|
|
||||||
`pairElement("ATCGA")` should return `[["A","T"],["T","A"],["C","G"],["G","C"],["A","T"]]`.
|
`pairElement("ATCGA")` debe devolver `[["A","T"],["T","A"],["C","G"],["G","C"],["A","T"]]`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.deepEqual(pairElement('ATCGA'), [
|
assert.deepEqual(pairElement('ATCGA'), [
|
||||||
@ -32,7 +32,7 @@ assert.deepEqual(pairElement('ATCGA'), [
|
|||||||
]);
|
]);
|
||||||
```
|
```
|
||||||
|
|
||||||
`pairElement("TTGAG")` should return `[["T","A"],["T","A"],["G","C"],["A","T"],["G","C"]]`.
|
`pairElement("TTGAG")` debe devolver `[["T","A"],["T","A"],["G","C"],["A","T"],["G","C"]]`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.deepEqual(pairElement('TTGAG'), [
|
assert.deepEqual(pairElement('TTGAG'), [
|
||||||
@ -44,7 +44,7 @@ assert.deepEqual(pairElement('TTGAG'), [
|
|||||||
]);
|
]);
|
||||||
```
|
```
|
||||||
|
|
||||||
`pairElement("CTCTA")` should return `[["C","G"],["T","A"],["C","G"],["T","A"],["A","T"]]`.
|
`pairElement("CTCTA")` debe devolver `[["C","G"],["T","A"],["C","G"],["T","A"],["A","T"]]`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.deepEqual(pairElement('CTCTA'), [
|
assert.deepEqual(pairElement('CTCTA'), [
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
id: af4afb223120f7348cdfc9fd
|
id: af4afb223120f7348cdfc9fd
|
||||||
title: Map the Debris
|
title: Mapea el Debris
|
||||||
challengeType: 5
|
challengeType: 5
|
||||||
forumTopicId: 16021
|
forumTopicId: 16021
|
||||||
dashedName: map-the-debris
|
dashedName: map-the-debris
|
||||||
@ -8,19 +8,19 @@ dashedName: map-the-debris
|
|||||||
|
|
||||||
# --description--
|
# --description--
|
||||||
|
|
||||||
Return a new array that transforms the elements' average altitude into their orbital periods (in seconds).
|
Devuelve un nuevo arreglo que transforma la altitud media de los elementos en sus periodos orbitales (en segundos).
|
||||||
|
|
||||||
The array will contain objects in the format `{name: 'name', avgAlt: avgAlt}`.
|
El arreglo contendrá objetos en el formato `{name: 'name', avgAlt: avgAlt}`.
|
||||||
|
|
||||||
You can read about orbital periods [on Wikipedia](http://en.wikipedia.org/wiki/Orbital_period).
|
Puedes leer sobre los períodos orbitales [en Wikipedia](https://es.wikipedia.org/wiki/Per%C3%Adodo_orbital).
|
||||||
|
|
||||||
The values should be rounded to the nearest whole number. The body being orbited is Earth.
|
Los valores deben redondearse al número entero más cercano. El cuerpo orbitado es la Tierra.
|
||||||
|
|
||||||
The radius of the earth is 6367.4447 kilometers, and the GM value of earth is 398600.4418 km<sup>3</sup>s<sup>-2</sup>.
|
El radio de la tierra es de 6367.4447 kilómetros y el valor GM de la tierra es de 398600.4418 km<sup>3</sup>s<sup>-2</sup>.
|
||||||
|
|
||||||
# --hints--
|
# --hints--
|
||||||
|
|
||||||
`orbitalPeriod([{name : "sputnik", avgAlt : 35873.5553}])` should return `[{name: "sputnik", orbitalPeriod: 86400}]`.
|
`orbitalPeriod([{name : "sputnik", avgAlt : 35873.5553}])` debe devolver `[{name: "sputnik", orbitalPeriod: 86400}]`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.deepEqual(orbitalPeriod([{ name: 'sputnik', avgAlt: 35873.5553 }]), [
|
assert.deepEqual(orbitalPeriod([{ name: 'sputnik', avgAlt: 35873.5553 }]), [
|
||||||
@ -28,7 +28,7 @@ assert.deepEqual(orbitalPeriod([{ name: 'sputnik', avgAlt: 35873.5553 }]), [
|
|||||||
]);
|
]);
|
||||||
```
|
```
|
||||||
|
|
||||||
`orbitalPeriod([{name: "iss", avgAlt: 413.6}, {name: "hubble", avgAlt: 556.7}, {name: "moon", avgAlt: 378632.553}])` should return `[{name : "iss", orbitalPeriod: 5557}, {name: "hubble", orbitalPeriod: 5734}, {name: "moon", orbitalPeriod: 2377399}]`.
|
`orbitalPeriod([{name: "iss", avgAlt: 413.6}, {name: "hubble", avgAlt: 556.7}, {name: "moon", avgAlt: 378632.553}])` debe devolver `[{name : "iss", orbitalPeriod: 5557}, {name: "hubble", orbitalPeriod: 5734}, {name: "moon", orbitalPeriod: 2377399}]`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
id: a8e512fbe388ac2f9198f0fa
|
id: a8e512fbe388ac2f9198f0fa
|
||||||
title: Wherefore art thou
|
title: Donde estás
|
||||||
challengeType: 5
|
challengeType: 5
|
||||||
forumTopicId: 16092
|
forumTopicId: 16092
|
||||||
dashedName: wherefore-art-thou
|
dashedName: wherefore-art-thou
|
||||||
@ -8,13 +8,13 @@ dashedName: wherefore-art-thou
|
|||||||
|
|
||||||
# --description--
|
# --description--
|
||||||
|
|
||||||
Make a function that looks through an array of objects (first argument) and returns an array of all objects that have matching name and value pairs (second argument). Each name and value pair of the source object has to be present in the object from the collection if it is to be included in the returned array.
|
Crea una función que busque a través de un arreglo de objetos (primer argumento) y devuelva un arreglo de todos los objetos que tengan pares de nombre y valor coincidentes (segundo argumento). Cada par de nombre y valor del objeto fuente tiene que estar presente en el objeto de la colección si se va a incluir en el arreglo devuelto.
|
||||||
|
|
||||||
For example, if the first argument is `[{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }]`, and the second argument is `{ last: "Capulet" }`, then you must return the third object from the array (the first argument), because it contains the name and its value, that was passed on as the second argument.
|
Por ejemplo, si el primer argumento es `[{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }]`, y el segundo argumento es `{ last: "Capulet" }`, entonces debes devolver el tercer objeto del arreglo (el primer argumento), porque contiene el nombre y su valor, el cual fue pasado como segundo argumento.
|
||||||
|
|
||||||
# --hints--
|
# --hints--
|
||||||
|
|
||||||
`whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" })` should return `[{ first: "Tybalt", last: "Capulet" }]`.
|
`whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" })` debe devolver `[{ first: "Tybalt", last: "Capulet" }]`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
@ -30,7 +30,7 @@ assert.deepEqual(
|
|||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
`whatIsInAName([{ "apple": 1 }, { "apple": 1 }, { "apple": 1, "bat": 2 }], { "apple": 1 })` should return `[{ "apple": 1 }, { "apple": 1 }, { "apple": 1, "bat": 2 }]`.
|
`whatIsInAName([{ "apple": 1 }, { "apple": 1 }, { "apple": 1, "bat": 2 }], { "apple": 1 })` debe devolver `[{ "apple": 1 }, { "apple": 1 }, { "apple": 1, "bat": 2 }]`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
@ -41,7 +41,7 @@ assert.deepEqual(
|
|||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
`whatIsInAName([{ "apple": 1, "bat": 2 }, { "bat": 2 }, { "apple": 1, "bat": 2, "cookie": 2 }], { "apple": 1, "bat": 2 })` should return `[{ "apple": 1, "bat": 2 }, { "apple": 1, "bat": 2, "cookie": 2 }]`.
|
`whatIsInAName([{ "apple": 1, "bat": 2 }, { "bat": 2 }, { "apple": 1, "bat": 2, "cookie": 2 }], { "apple": 1, "bat": 2 })` debe devolver `[{ "apple": 1, "bat": 2 }, { "apple": 1, "bat": 2, "cookie": 2 }]`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
@ -56,7 +56,7 @@ assert.deepEqual(
|
|||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
`whatIsInAName([{ "apple": 1, "bat": 2 }, { "apple": 1 }, { "apple": 1, "bat": 2, "cookie": 2 }], { "apple": 1, "cookie": 2 })` should return `[{ "apple": 1, "bat": 2, "cookie": 2 }]`.
|
`whatIsInAName([{ "apple": 1, "bat": 2 }, { "apple": 1 }, { "apple": 1, "bat": 2, "cookie": 2 }], { "apple": 1, "cookie": 2 })` debe devolver `[{ "apple": 1, "bat": 2, "cookie": 2 }]`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
@ -68,7 +68,7 @@ assert.deepEqual(
|
|||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
`whatIsInAName([{ "apple": 1, "bat": 2 }, { "apple": 1 }, { "apple": 1, "bat": 2, "cookie": 2 }, { "bat":2 }], { "apple": 1, "bat": 2 })` should return `[{ "apple": 1, "bat": 2 }, { "apple": 1, "bat": 2, "cookie":2 }]`.
|
`whatIsInAName([{ "apple": 1, "bat": 2 }, { "apple": 1 }, { "apple": 1, "bat": 2, "cookie": 2 }, { "bat":2 }], { "apple": 1, "bat": 2 })` debe devolver `[{ "apple": 1, "bat": 2 }, { "apple": 1, "bat": 2, "cookie":2 }]`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
@ -88,7 +88,7 @@ assert.deepEqual(
|
|||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
`whatIsInAName([{"a": 1, "b": 2, "c": 3}], {"a": 1, "b": 9999, "c": 3})` should return `[]`
|
`whatIsInAName([{"a": 1, "b": 2, "c": 3}], {"a": 1, "b": 9999, "c": 3})` debe devolver `[]`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.deepEqual(
|
assert.deepEqual(
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
id: 56533eb9ac21ba0edf2244e2
|
id: 56533eb9ac21ba0edf2244e2
|
||||||
title: Caesars Cipher
|
title: Cifrado César
|
||||||
challengeType: 5
|
challengeType: 5
|
||||||
forumTopicId: 16003
|
forumTopicId: 16003
|
||||||
dashedName: caesars-cipher
|
dashedName: caesars-cipher
|
||||||
@ -8,35 +8,35 @@ dashedName: caesars-cipher
|
|||||||
|
|
||||||
# --description--
|
# --description--
|
||||||
|
|
||||||
One of the simplest and most widely known <dfn>ciphers</dfn> is a <dfn>Caesar cipher</dfn>, also known as a <dfn>shift cipher</dfn>. In a shift cipher the meanings of the letters are shifted by some set amount.
|
Uno de los <dfn>cifrados</dfn> más simples y conocidos es el <dfn>cifrado César</dfn>, también conocido como <dfn>cifrado por desplazamiento</dfn>. En un cifrado por desplazamiento los significados de las letras se desplazan por una cantidad determinada.
|
||||||
|
|
||||||
A common modern use is the [ROT13](https://en.wikipedia.org/wiki/ROT13) cipher, where the values of the letters are shifted by 13 places. Thus 'A' ↔ 'N', 'B' ↔ 'O' and so on.
|
Un uso moderno común es el cifrado [ROT13](https://en.wikipedia.org/wiki/ROT13), donde los valores de las letras son desplazados por 13 lugares. Así que `A ↔ N`, `B ↔ O` y así sucesivamente.
|
||||||
|
|
||||||
Write a function which takes a [ROT13](https://en.wikipedia.org/wiki/ROT13) encoded string as input and returns a decoded string.
|
Escribe una función que reciba una cadena codificada en [ROT13](https://en.wikipedia.org/wiki/ROT13) como entrada y devuelva una cadena decodificada.
|
||||||
|
|
||||||
All letters will be uppercase. Do not transform any non-alphabetic character (i.e. spaces, punctuation), but do pass them on.
|
Todas las letras estarán en mayúsculas. No transformes ningún carácter no alfabético (espacios, puntuación, por ejemplo), pero si transmítelos.
|
||||||
|
|
||||||
# --hints--
|
# --hints--
|
||||||
|
|
||||||
`rot13("SERR PBQR PNZC")` should decode to `FREE CODE CAMP`
|
`rot13("SERR PBQR PNZC")` debe decodificarse en la cadena `FREE CODE CAMP`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(rot13('SERR PBQR PNZC') === 'FREE CODE CAMP');
|
assert(rot13('SERR PBQR PNZC') === 'FREE CODE CAMP');
|
||||||
```
|
```
|
||||||
|
|
||||||
`rot13("SERR CVMMN!")` should decode to `FREE PIZZA!`
|
`rot13("SERR CVMMN!")` debe decodificarse en la cadena `FREE PIZZA!`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(rot13('SERR CVMMN!') === 'FREE PIZZA!');
|
assert(rot13('SERR CVMMN!') === 'FREE PIZZA!');
|
||||||
```
|
```
|
||||||
|
|
||||||
`rot13("SERR YBIR?")` should decode to `FREE LOVE?`
|
`rot13("SERR YBIR?")` debe decodificarse en la cadena `FREE LOVE?`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(rot13('SERR YBIR?') === 'FREE LOVE?');
|
assert(rot13('SERR YBIR?') === 'FREE LOVE?');
|
||||||
```
|
```
|
||||||
|
|
||||||
`rot13("GUR DHVPX OEBJA SBK WHZCF BIRE GUR YNML QBT.")` should decode to `THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG.`
|
`rot13("GUR DHVPX OEBJA SBK WHZCF BIRE GUR YNML QBT.")` debe decodificarse en la cadena `THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG.`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(
|
assert(
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
id: aaa48de84e1ecc7c742e1124
|
id: aaa48de84e1ecc7c742e1124
|
||||||
title: Palindrome Checker
|
title: Comprobador de palíndromos
|
||||||
challengeType: 5
|
challengeType: 5
|
||||||
forumTopicId: 16004
|
forumTopicId: 16004
|
||||||
dashedName: palindrome-checker
|
dashedName: palindrome-checker
|
||||||
@ -8,91 +8,91 @@ dashedName: palindrome-checker
|
|||||||
|
|
||||||
# --description--
|
# --description--
|
||||||
|
|
||||||
Return `true` if the given string is a palindrome. Otherwise, return `false`.
|
Devuelve `true` si la cadena proporcionada es un palíndromo. De lo contrario, devuelve `false`.
|
||||||
|
|
||||||
A <dfn>palindrome</dfn> is a word or sentence that's spelled the same way both forward and backward, ignoring punctuation, case, and spacing.
|
Un <dfn>palíndromo</dfn> es una palabra o frase que se escribe de la misma manera hacia adelante y hacia atrás, ignorando la puntuación, mayúsculas, minúsculas y espaciado.
|
||||||
|
|
||||||
**Note:** You'll need to remove **all non-alphanumeric characters** (punctuation, spaces and symbols) and turn everything into the same case (lower or upper case) in order to check for palindromes.
|
**Nota:** Tendrás que eliminar **todos los caracteres no alfanuméricos** (puntuación, espacios y símbolos) y convertir todo en mayúsculas o minúsculas para comprobar si hay palíndromos.
|
||||||
|
|
||||||
We'll pass strings with varying formats, such as `"racecar"`, `"RaceCar"`, and `"race CAR"` among others.
|
Pasaremos cadenas con formatos variables, como `racecar`, `RaceCar` y `race CAR` entre otros.
|
||||||
|
|
||||||
We'll also pass strings with special symbols, such as `"2A3*3a2"`, `"2A3 3a2"`, and `"2_A3*3#A2"`.
|
También pasaremos cadenas con símbolos especiales, como `2A3*3a2`, `2A3 3a2` y `2_A3*3#A2`.
|
||||||
|
|
||||||
# --hints--
|
# --hints--
|
||||||
|
|
||||||
`palindrome("eye")` should return a boolean.
|
`palindrome("eye")` debe devolver un booleano.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(typeof palindrome('eye') === 'boolean');
|
assert(typeof palindrome('eye') === 'boolean');
|
||||||
```
|
```
|
||||||
|
|
||||||
`palindrome("eye")` should return true.
|
`palindrome("eye")` debe devolver `true`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(palindrome('eye') === true);
|
assert(palindrome('eye') === true);
|
||||||
```
|
```
|
||||||
|
|
||||||
`palindrome("_eye")` should return true.
|
`palindrome("_eye")` debe devolver `true`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(palindrome('_eye') === true);
|
assert(palindrome('_eye') === true);
|
||||||
```
|
```
|
||||||
|
|
||||||
`palindrome("race car")` should return true.
|
`palindrome("race car")` debe devolver `true`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(palindrome('race car') === true);
|
assert(palindrome('race car') === true);
|
||||||
```
|
```
|
||||||
|
|
||||||
`palindrome("not a palindrome")` should return false.
|
`palindrome("not a palindrome")` debe devolver `false`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(palindrome('not a palindrome') === false);
|
assert(palindrome('not a palindrome') === false);
|
||||||
```
|
```
|
||||||
|
|
||||||
`palindrome("A man, a plan, a canal. Panama")` should return true.
|
`palindrome("A man, a plan, a canal. Panama")` debe devolver `true`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(palindrome('A man, a plan, a canal. Panama') === true);
|
assert(palindrome('A man, a plan, a canal. Panama') === true);
|
||||||
```
|
```
|
||||||
|
|
||||||
`palindrome("never odd or even")` should return true.
|
`palindrome("never odd or even")` debe devolver `true`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(palindrome('never odd or even') === true);
|
assert(palindrome('never odd or even') === true);
|
||||||
```
|
```
|
||||||
|
|
||||||
`palindrome("nope")` should return false.
|
`palindrome("nope")` debe devolver `false`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(palindrome('nope') === false);
|
assert(palindrome('nope') === false);
|
||||||
```
|
```
|
||||||
|
|
||||||
`palindrome("almostomla")` should return false.
|
`palindrome("almostomla")` debe devolver `false`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(palindrome('almostomla') === false);
|
assert(palindrome('almostomla') === false);
|
||||||
```
|
```
|
||||||
|
|
||||||
`palindrome("My age is 0, 0 si ega ym.")` should return true.
|
`palindrome("My age is 0, 0 si ega ym.")` debe devolver `true`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(palindrome('My age is 0, 0 si ega ym.') === true);
|
assert(palindrome('My age is 0, 0 si ega ym.') === true);
|
||||||
```
|
```
|
||||||
|
|
||||||
`palindrome("1 eye for of 1 eye.")` should return false.
|
`palindrome("1 eye for of 1 eye.")` debe devolver `false`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(palindrome('1 eye for of 1 eye.') === false);
|
assert(palindrome('1 eye for of 1 eye.') === false);
|
||||||
```
|
```
|
||||||
|
|
||||||
`palindrome("0_0 (: /-\ :) 0-0")` should return true.
|
`palindrome("0_0 (: /-\ :) 0-0")` debe devolver `true`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(palindrome('0_0 (: /- :) 0-0') === true);
|
assert(palindrome('0_0 (: /- :) 0-0') === true);
|
||||||
```
|
```
|
||||||
|
|
||||||
`palindrome("five|\_/|four")` should return false.
|
`palindrome("five|\_/|four")` debe devolver `false`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(palindrome('five|_/|four') === false);
|
assert(palindrome('five|_/|four') === false);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
id: a7f4d8f2483413a6ce226cac
|
id: a7f4d8f2483413a6ce226cac
|
||||||
title: Roman Numeral Converter
|
title: Conversor de números romanos
|
||||||
challengeType: 5
|
challengeType: 5
|
||||||
forumTopicId: 16044
|
forumTopicId: 16044
|
||||||
dashedName: roman-numeral-converter
|
dashedName: roman-numeral-converter
|
||||||
@ -8,163 +8,163 @@ dashedName: roman-numeral-converter
|
|||||||
|
|
||||||
# --description--
|
# --description--
|
||||||
|
|
||||||
Convert the given number into a roman numeral.
|
Convierte el número proporcionado en un número romano.
|
||||||
|
|
||||||
All [roman numerals](http://www.mathsisfun.com/roman-numerals.html) answers should be provided in upper-case.
|
Todos los [números romanos](http://www.mathsisfun.com/roman-numerals.html) deben proporcionarse en mayusculas.
|
||||||
|
|
||||||
# --hints--
|
# --hints--
|
||||||
|
|
||||||
`convertToRoman(2)` should return "II".
|
`convertToRoman(2)` debe devolver la cadena `II`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.deepEqual(convertToRoman(2), 'II');
|
assert.deepEqual(convertToRoman(2), 'II');
|
||||||
```
|
```
|
||||||
|
|
||||||
`convertToRoman(3)` should return "III".
|
`convertToRoman(3)` debe devolver la cadena `III`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.deepEqual(convertToRoman(3), 'III');
|
assert.deepEqual(convertToRoman(3), 'III');
|
||||||
```
|
```
|
||||||
|
|
||||||
`convertToRoman(4)` should return "IV".
|
`convertToRoman(4)` debe devolver la cadena `IV`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.deepEqual(convertToRoman(4), 'IV');
|
assert.deepEqual(convertToRoman(4), 'IV');
|
||||||
```
|
```
|
||||||
|
|
||||||
`convertToRoman(5)` should return "V".
|
`convertToRoman(5)` debe devolver la cadena `V`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.deepEqual(convertToRoman(5), 'V');
|
assert.deepEqual(convertToRoman(5), 'V');
|
||||||
```
|
```
|
||||||
|
|
||||||
`convertToRoman(9)` should return "IX".
|
`convertToRoman(9)` debe devolver la cadena `IX`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.deepEqual(convertToRoman(9), 'IX');
|
assert.deepEqual(convertToRoman(9), 'IX');
|
||||||
```
|
```
|
||||||
|
|
||||||
`convertToRoman(12)` should return "XII".
|
`convertToRoman(12)` debe devolver la cadena `XII`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.deepEqual(convertToRoman(12), 'XII');
|
assert.deepEqual(convertToRoman(12), 'XII');
|
||||||
```
|
```
|
||||||
|
|
||||||
`convertToRoman(16)` should return "XVI".
|
`convertToRoman(16)` debe devolver la cadena `XVI`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.deepEqual(convertToRoman(16), 'XVI');
|
assert.deepEqual(convertToRoman(16), 'XVI');
|
||||||
```
|
```
|
||||||
|
|
||||||
`convertToRoman(29)` should return "XXIX".
|
`convertToRoman(29)` debe devolver la cadena `XXIX`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.deepEqual(convertToRoman(29), 'XXIX');
|
assert.deepEqual(convertToRoman(29), 'XXIX');
|
||||||
```
|
```
|
||||||
|
|
||||||
`convertToRoman(44)` should return "XLIV".
|
`convertToRoman(44)` debe devolver la cadena `XLIV`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.deepEqual(convertToRoman(44), 'XLIV');
|
assert.deepEqual(convertToRoman(44), 'XLIV');
|
||||||
```
|
```
|
||||||
|
|
||||||
`convertToRoman(45)` should return "XLV"
|
`convertToRoman(45)` debe devolver la cadena `XLV`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.deepEqual(convertToRoman(45), 'XLV');
|
assert.deepEqual(convertToRoman(45), 'XLV');
|
||||||
```
|
```
|
||||||
|
|
||||||
`convertToRoman(68)` should return "LXVIII"
|
`convertToRoman(68)` debe devolver la cadena `LXVIII`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.deepEqual(convertToRoman(68), 'LXVIII');
|
assert.deepEqual(convertToRoman(68), 'LXVIII');
|
||||||
```
|
```
|
||||||
|
|
||||||
`convertToRoman(83)` should return "LXXXIII"
|
`convertToRoman(83)` debe devolver la cadena `LXXXIII`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.deepEqual(convertToRoman(83), 'LXXXIII');
|
assert.deepEqual(convertToRoman(83), 'LXXXIII');
|
||||||
```
|
```
|
||||||
|
|
||||||
`convertToRoman(97)` should return "XCVII"
|
`convertToRoman(97)` debe devolver la cadena `XCVII`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.deepEqual(convertToRoman(97), 'XCVII');
|
assert.deepEqual(convertToRoman(97), 'XCVII');
|
||||||
```
|
```
|
||||||
|
|
||||||
`convertToRoman(99)` should return "XCIX"
|
`convertToRoman(99)` debe devolver la cadena `XCIX`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.deepEqual(convertToRoman(99), 'XCIX');
|
assert.deepEqual(convertToRoman(99), 'XCIX');
|
||||||
```
|
```
|
||||||
|
|
||||||
`convertToRoman(400)` should return "CD"
|
`convertToRoman(400)` debe devolver la cadena `CD`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.deepEqual(convertToRoman(400), 'CD');
|
assert.deepEqual(convertToRoman(400), 'CD');
|
||||||
```
|
```
|
||||||
|
|
||||||
`convertToRoman(500)` should return "D"
|
`convertToRoman(500)` debe devolver la cadena `D`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.deepEqual(convertToRoman(500), 'D');
|
assert.deepEqual(convertToRoman(500), 'D');
|
||||||
```
|
```
|
||||||
|
|
||||||
`convertToRoman(501)` should return "DI"
|
`convertToRoman(501)` debe devolver la cadena `DI`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.deepEqual(convertToRoman(501), 'DI');
|
assert.deepEqual(convertToRoman(501), 'DI');
|
||||||
```
|
```
|
||||||
|
|
||||||
`convertToRoman(649)` should return "DCXLIX"
|
`convertToRoman(649)` debe devolver la cadena `DCXLIX`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.deepEqual(convertToRoman(649), 'DCXLIX');
|
assert.deepEqual(convertToRoman(649), 'DCXLIX');
|
||||||
```
|
```
|
||||||
|
|
||||||
`convertToRoman(798)` should return "DCCXCVIII"
|
`convertToRoman(798)` debe devolver la cadena `DCCXCVIII`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.deepEqual(convertToRoman(798), 'DCCXCVIII');
|
assert.deepEqual(convertToRoman(798), 'DCCXCVIII');
|
||||||
```
|
```
|
||||||
|
|
||||||
`convertToRoman(891)` should return "DCCCXCI"
|
`convertToRoman(891)` debe devolver la cadena `DCCCXCI`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.deepEqual(convertToRoman(891), 'DCCCXCI');
|
assert.deepEqual(convertToRoman(891), 'DCCCXCI');
|
||||||
```
|
```
|
||||||
|
|
||||||
`convertToRoman(1000)` should return "M"
|
`convertToRoman(1000)` debe devolver la cadena `M`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.deepEqual(convertToRoman(1000), 'M');
|
assert.deepEqual(convertToRoman(1000), 'M');
|
||||||
```
|
```
|
||||||
|
|
||||||
`convertToRoman(1004)` should return "MIV"
|
`convertToRoman(1004)` debe devolver la cadena `MIV`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.deepEqual(convertToRoman(1004), 'MIV');
|
assert.deepEqual(convertToRoman(1004), 'MIV');
|
||||||
```
|
```
|
||||||
|
|
||||||
`convertToRoman(1006)` should return "MVI"
|
`convertToRoman(1006)` debe devolver la cadena `MVI`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.deepEqual(convertToRoman(1006), 'MVI');
|
assert.deepEqual(convertToRoman(1006), 'MVI');
|
||||||
```
|
```
|
||||||
|
|
||||||
`convertToRoman(1023)` should return "MXXIII"
|
`convertToRoman(1023)` debe devolver la cadena `MXXIII`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.deepEqual(convertToRoman(1023), 'MXXIII');
|
assert.deepEqual(convertToRoman(1023), 'MXXIII');
|
||||||
```
|
```
|
||||||
|
|
||||||
`convertToRoman(2014)` should return "MMXIV"
|
`convertToRoman(2014)` debe devolver la cadena `MMXIV`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.deepEqual(convertToRoman(2014), 'MMXIV');
|
assert.deepEqual(convertToRoman(2014), 'MMXIV');
|
||||||
```
|
```
|
||||||
|
|
||||||
`convertToRoman(3999)` should return "MMMCMXCIX"
|
`convertToRoman(3999)` debe devolver la cadena `MMMCMXCIX`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert.deepEqual(convertToRoman(3999), 'MMMCMXCIX');
|
assert.deepEqual(convertToRoman(3999), 'MMMCMXCIX');
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
id: aff0395860f5d3034dc0bfc9
|
id: aff0395860f5d3034dc0bfc9
|
||||||
title: Telephone Number Validator
|
title: Validador de números telefónicos
|
||||||
challengeType: 5
|
challengeType: 5
|
||||||
forumTopicId: 16090
|
forumTopicId: 16090
|
||||||
dashedName: telephone-number-validator
|
dashedName: telephone-number-validator
|
||||||
@ -8,173 +8,173 @@ dashedName: telephone-number-validator
|
|||||||
|
|
||||||
# --description--
|
# --description--
|
||||||
|
|
||||||
Return `true` if the passed string looks like a valid US phone number.
|
Devuelve `true` si la cadena pasada concuerda con un número de teléfono válido en Estados Unidos.
|
||||||
|
|
||||||
The user may fill out the form field any way they choose as long as it has the format of a valid US number. The following are examples of valid formats for US numbers (refer to the tests below for other variants):
|
El usuario puede completar el campo del formulario de la forma que elija, siempre que tenga el formato de un número estadounidense válido. Los siguientes ejemplos son de formatos válidos para números estadounidenses (consulte las pruebas a continuación para otras variantes):
|
||||||
|
|
||||||
<blockquote>555-555-5555<br>(555)555-5555<br>(555) 555-5555<br>555 555 5555<br>5555555555<br>1 555 555 5555</blockquote>
|
<blockquote>555-555-5555<br>(555)555-5555<br>(555) 555-5555<br>555 555 5555<br>5555555555<br>1 555 555 5555</blockquote>
|
||||||
|
|
||||||
For this challenge you will be presented with a string such as `800-692-7753` or `8oo-six427676;laskdjf`. Your job is to validate or reject the US phone number based on any combination of the formats provided above. The area code is required. If the country code is provided, you must confirm that the country code is `1`. Return `true` if the string is a valid US phone number; otherwise return `false`.
|
Para este desafío se te presentará una cadena como `800-692-7753` o `8oo-six427676;laskdjf`. Tu trabajo es validar o rechazar el número de teléfono estadounidense basado en cualquier combinación de los formatos proporcionados arriba. El código de área es obligatorio. Si el código de país es proporcionado, debes confirmar que el código de país es `1`. Devuelve `true` si la cadena es un número de teléfono estadounidense valido; de lo contrario devuelve `false`.
|
||||||
|
|
||||||
# --hints--
|
# --hints--
|
||||||
|
|
||||||
`telephoneCheck("555-555-5555")` should return a boolean.
|
`telephoneCheck("555-555-5555")` debe devolver un booleano.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(typeof telephoneCheck('555-555-5555') === 'boolean');
|
assert(typeof telephoneCheck('555-555-5555') === 'boolean');
|
||||||
```
|
```
|
||||||
|
|
||||||
`telephoneCheck("1 555-555-5555")` should return true.
|
`telephoneCheck("1 555-555-5555")` debe devolver `true`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(telephoneCheck('1 555-555-5555') === true);
|
assert(telephoneCheck('1 555-555-5555') === true);
|
||||||
```
|
```
|
||||||
|
|
||||||
`telephoneCheck("1 (555) 555-5555")` should return true.
|
`telephoneCheck("1 (555) 555-5555")` debe devolver `true`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(telephoneCheck('1 (555) 555-5555') === true);
|
assert(telephoneCheck('1 (555) 555-5555') === true);
|
||||||
```
|
```
|
||||||
|
|
||||||
`telephoneCheck("5555555555")` should return true.
|
`telephoneCheck("5555555555")` debe devolver `true`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(telephoneCheck('5555555555') === true);
|
assert(telephoneCheck('5555555555') === true);
|
||||||
```
|
```
|
||||||
|
|
||||||
`telephoneCheck("555-555-5555")` should return true.
|
`telephoneCheck("555-555-5555")` debe devolver `true`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(telephoneCheck('555-555-5555') === true);
|
assert(telephoneCheck('555-555-5555') === true);
|
||||||
```
|
```
|
||||||
|
|
||||||
`telephoneCheck("(555)555-5555")` should return true.
|
`telephoneCheck("(555)555-5555")` debe devolver `true`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(telephoneCheck('(555)555-5555') === true);
|
assert(telephoneCheck('(555)555-5555') === true);
|
||||||
```
|
```
|
||||||
|
|
||||||
`telephoneCheck("1(555)555-5555")` should return true.
|
`telephoneCheck("1(555)555-5555")` debe devolver `true`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(telephoneCheck('1(555)555-5555') === true);
|
assert(telephoneCheck('1(555)555-5555') === true);
|
||||||
```
|
```
|
||||||
|
|
||||||
`telephoneCheck("555-5555")` should return false.
|
`telephoneCheck("555-5555")` debe devolver `false`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(telephoneCheck('555-5555') === false);
|
assert(telephoneCheck('555-5555') === false);
|
||||||
```
|
```
|
||||||
|
|
||||||
`telephoneCheck("5555555")` should return false.
|
`telephoneCheck("5555555")` debe devolver `false`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(telephoneCheck('5555555') === false);
|
assert(telephoneCheck('5555555') === false);
|
||||||
```
|
```
|
||||||
|
|
||||||
`telephoneCheck("1 555)555-5555")` should return false.
|
`telephoneCheck("1 555)555-5555")` debe devolver `false`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(telephoneCheck('1 555)555-5555') === false);
|
assert(telephoneCheck('1 555)555-5555') === false);
|
||||||
```
|
```
|
||||||
|
|
||||||
`telephoneCheck("1 555 555 5555")` should return true.
|
`telephoneCheck("1 555 555 5555")` debe devolver `true`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(telephoneCheck('1 555 555 5555') === true);
|
assert(telephoneCheck('1 555 555 5555') === true);
|
||||||
```
|
```
|
||||||
|
|
||||||
`telephoneCheck("1 456 789 4444")` should return true.
|
`telephoneCheck("1 456 789 4444")` debe devolver `true`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(telephoneCheck('1 456 789 4444') === true);
|
assert(telephoneCheck('1 456 789 4444') === true);
|
||||||
```
|
```
|
||||||
|
|
||||||
`telephoneCheck("123**&!!asdf#")` should return false.
|
`telephoneCheck("123**&!!asdf#")` debe devolver `false`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(telephoneCheck('123**&!!asdf#') === false);
|
assert(telephoneCheck('123**&!!asdf#') === false);
|
||||||
```
|
```
|
||||||
|
|
||||||
`telephoneCheck("55555555")` should return false.
|
`telephoneCheck("55555555")` debe devolver `false`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(telephoneCheck('55555555') === false);
|
assert(telephoneCheck('55555555') === false);
|
||||||
```
|
```
|
||||||
|
|
||||||
`telephoneCheck("(6054756961)")` should return false
|
`telephoneCheck("(6054756961)")` debe devolver `false`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(telephoneCheck('(6054756961)') === false);
|
assert(telephoneCheck('(6054756961)') === false);
|
||||||
```
|
```
|
||||||
|
|
||||||
`telephoneCheck("2 (757) 622-7382")` should return false.
|
`telephoneCheck("2 (757) 622-7382")` debe devolver `false`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(telephoneCheck('2 (757) 622-7382') === false);
|
assert(telephoneCheck('2 (757) 622-7382') === false);
|
||||||
```
|
```
|
||||||
|
|
||||||
`telephoneCheck("0 (757) 622-7382")` should return false.
|
`telephoneCheck("0 (757) 622-7382")` debe devolver `false`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(telephoneCheck('0 (757) 622-7382') === false);
|
assert(telephoneCheck('0 (757) 622-7382') === false);
|
||||||
```
|
```
|
||||||
|
|
||||||
`telephoneCheck("-1 (757) 622-7382")` should return false
|
`telephoneCheck("-1 (757) 622-7382")` debe devolver `false`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(telephoneCheck('-1 (757) 622-7382') === false);
|
assert(telephoneCheck('-1 (757) 622-7382') === false);
|
||||||
```
|
```
|
||||||
|
|
||||||
`telephoneCheck("2 757 622-7382")` should return false.
|
`telephoneCheck("2 757 622-7382")` debe devolver `false`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(telephoneCheck('2 757 622-7382') === false);
|
assert(telephoneCheck('2 757 622-7382') === false);
|
||||||
```
|
```
|
||||||
|
|
||||||
`telephoneCheck("10 (757) 622-7382")` should return false.
|
`telephoneCheck("10 (757) 622-7382")` debe devolver `false`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(telephoneCheck('10 (757) 622-7382') === false);
|
assert(telephoneCheck('10 (757) 622-7382') === false);
|
||||||
```
|
```
|
||||||
|
|
||||||
`telephoneCheck("27576227382")` should return false.
|
`telephoneCheck("27576227382")` debe devolver `false`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(telephoneCheck('27576227382') === false);
|
assert(telephoneCheck('27576227382') === false);
|
||||||
```
|
```
|
||||||
|
|
||||||
`telephoneCheck("(275)76227382")` should return false.
|
`telephoneCheck("(275)76227382")` debe devolver `false`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(telephoneCheck('(275)76227382') === false);
|
assert(telephoneCheck('(275)76227382') === false);
|
||||||
```
|
```
|
||||||
|
|
||||||
`telephoneCheck("2(757)6227382")` should return false.
|
`telephoneCheck("2(757)6227382")` debe devolver `false`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(telephoneCheck('2(757)6227382') === false);
|
assert(telephoneCheck('2(757)6227382') === false);
|
||||||
```
|
```
|
||||||
|
|
||||||
`telephoneCheck("2(757)622-7382")` should return false.
|
`telephoneCheck("2(757)622-7382")` debe devolver `false`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(telephoneCheck('2(757)622-7382') === false);
|
assert(telephoneCheck('2(757)622-7382') === false);
|
||||||
```
|
```
|
||||||
|
|
||||||
`telephoneCheck("555)-555-5555")` should return false.
|
`telephoneCheck("555)-555-5555")` debe devolver `false`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(telephoneCheck('555)-555-5555') === false);
|
assert(telephoneCheck('555)-555-5555') === false);
|
||||||
```
|
```
|
||||||
|
|
||||||
`telephoneCheck("(555-555-5555")` should return false.
|
`telephoneCheck("(555-555-5555")` debe devolver `false`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(telephoneCheck('(555-555-5555') === false);
|
assert(telephoneCheck('(555-555-5555') === false);
|
||||||
```
|
```
|
||||||
|
|
||||||
`telephoneCheck("(555)5(55?)-5555")` should return false.
|
`telephoneCheck("(555)5(55?)-5555")` debe devolver `false`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(telephoneCheck('(555)5(55?)-5555') === false);
|
assert(telephoneCheck('(555)5(55?)-5555') === false);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
id: 587d7db1367417b2b2512b87
|
id: 587d7db1367417b2b2512b87
|
||||||
title: Add Methods After Inheritance
|
title: Añade métodos después de la herencia
|
||||||
challengeType: 1
|
challengeType: 1
|
||||||
forumTopicId: 301315
|
forumTopicId: 301315
|
||||||
dashedName: add-methods-after-inheritance
|
dashedName: add-methods-after-inheritance
|
||||||
@ -8,9 +8,9 @@ dashedName: add-methods-after-inheritance
|
|||||||
|
|
||||||
# --description--
|
# --description--
|
||||||
|
|
||||||
A constructor function that inherits its `prototype` object from a supertype constructor function can still have its own methods in addition to inherited methods.
|
Una función constructor que hereda su objeto `prototype` de una función constructor "supertype" puede seguir teniendo sus propios métodos además de los heredados.
|
||||||
|
|
||||||
For example, `Bird` is a constructor that inherits its `prototype` from `Animal`:
|
Por ejemplo, `Bird` es un constructor que hereda su `prototype` de `Animal`:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
function Animal() { }
|
function Animal() { }
|
||||||
@ -22,7 +22,7 @@ Bird.prototype = Object.create(Animal.prototype);
|
|||||||
Bird.prototype.constructor = Bird;
|
Bird.prototype.constructor = Bird;
|
||||||
```
|
```
|
||||||
|
|
||||||
In addition to what is inherited from `Animal`, you want to add behavior that is unique to `Bird` objects. Here, `Bird` will get a `fly()` function. Functions are added to `Bird's` `prototype` the same way as any constructor function:
|
Además de lo que se hereda de `Animal`, se quiere añadir un comportamiento que sea exclusivo de los objetos `Bird`. Aquí, `Bird` obtendrá una función `fly()`. Las funciones se añaden al `prototype` de `Bird's` del mismo modo que cualquier función constructor:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
Bird.prototype.fly = function() {
|
Bird.prototype.fly = function() {
|
||||||
@ -30,51 +30,53 @@ Bird.prototype.fly = function() {
|
|||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
Now instances of `Bird` will have both `eat()` and `fly()` methods:
|
Ahora las instancias de `Bird` tendrán métodos tanto `eat()` como `fly()`:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
let duck = new Bird();
|
let duck = new Bird();
|
||||||
duck.eat(); // prints "nom nom nom"
|
duck.eat();
|
||||||
duck.fly(); // prints "I'm flying!"
|
duck.fly();
|
||||||
```
|
```
|
||||||
|
|
||||||
|
`duck.eat()` mostrará la cadena `nom nom nom` en consola, y `duck.fly()` mostrará la cadena `I'm flying!`.
|
||||||
|
|
||||||
# --instructions--
|
# --instructions--
|
||||||
|
|
||||||
Add all necessary code so the `Dog` object inherits from `Animal` and the `Dog's` `prototype` constructor is set to Dog. Then add a `bark()` method to the `Dog` object so that `beagle` can both `eat()` and `bark()`. The `bark()` method should print "Woof!" to the console.
|
Añade el código necesario para que el objeto `Dog` herede de `Animal` y el constructor `prototype` de `Dog` sea establecido en `Dog`. A continuación agrega el método `bark()` al objeto `Dog`, para que `beagle` pueda "comer" `eat()` y "ladrar" `bark()`. El método `bark()` debe imprimir `Woof!` por consola.
|
||||||
|
|
||||||
# --hints--
|
# --hints--
|
||||||
|
|
||||||
`Animal` should not respond to the `bark()` method.
|
`Animal` no debe responder al método `bark()`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(typeof Animal.prototype.bark == 'undefined');
|
assert(typeof Animal.prototype.bark == 'undefined');
|
||||||
```
|
```
|
||||||
|
|
||||||
`Dog` should inherit the `eat()` method from `Animal`.
|
`Dog` debe heredar el método `eat()` de `Animal`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(typeof Dog.prototype.eat == 'function');
|
assert(typeof Dog.prototype.eat == 'function');
|
||||||
```
|
```
|
||||||
|
|
||||||
`Dog` should have the `bark()` method as an `own` property.
|
`Dog` debe tener el método `bark()` como una propiedad propia `own`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(Dog.prototype.hasOwnProperty('bark'));
|
assert(Dog.prototype.hasOwnProperty('bark'));
|
||||||
```
|
```
|
||||||
|
|
||||||
`beagle` should be an `instanceof` `Animal`.
|
`beagle` debe ser una instancia de (`instanceof`) `Animal`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(beagle instanceof Animal);
|
assert(beagle instanceof Animal);
|
||||||
```
|
```
|
||||||
|
|
||||||
The constructor for `beagle` should be set to `Dog`.
|
El constructor para `beagle` debe establecerse en `Dog`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(beagle.constructor === Dog);
|
assert(beagle.constructor === Dog);
|
||||||
```
|
```
|
||||||
|
|
||||||
`beagle.eat()` should log `"nom nom nom"`
|
`beagle.eat()` debe imprimir la cadena `nom nom nom`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
console.log = function (msg) {
|
console.log = function (msg) {
|
||||||
@ -83,7 +85,7 @@ console.log = function (msg) {
|
|||||||
assert.throws(() => beagle.eat(), 'nom nom nom');
|
assert.throws(() => beagle.eat(), 'nom nom nom');
|
||||||
```
|
```
|
||||||
|
|
||||||
`beagle.bark()` should log `"Woof!"`
|
`beagle.bark()` debe imprimir la cadena `Woof!`
|
||||||
|
|
||||||
```js
|
```js
|
||||||
console.log = function (msg) {
|
console.log = function (msg) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
id: 587d7db1367417b2b2512b85
|
id: 587d7db1367417b2b2512b85
|
||||||
title: Set the Child's Prototype to an Instance of the Parent
|
title: Establece el prototipo de hijo para una instancia del padre
|
||||||
challengeType: 1
|
challengeType: 1
|
||||||
forumTopicId: 301325
|
forumTopicId: 301325
|
||||||
dashedName: set-the-childs-prototype-to-an-instance-of-the-parent
|
dashedName: set-the-childs-prototype-to-an-instance-of-the-parent
|
||||||
@ -8,30 +8,30 @@ dashedName: set-the-childs-prototype-to-an-instance-of-the-parent
|
|||||||
|
|
||||||
# --description--
|
# --description--
|
||||||
|
|
||||||
In the previous challenge you saw the first step for inheriting behavior from the supertype (or parent) `Animal`: making a new instance of `Animal`.
|
En el desafío anterior, viste el primer paso para heredar el comportamiento del supertipo (o padre) `Animal`: creando una nueva instancia de `Animal`.
|
||||||
|
|
||||||
This challenge covers the next step: set the `prototype` of the subtype (or child)—in this case, `Bird`—to be an instance of `Animal`.
|
Este desafío cubre el siguiente paso: establecer el prototipo `prototype` del subtipo (o hijo) —en este caso, `Bird`— para ser una instancia de `Animal`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
Bird.prototype = Object.create(Animal.prototype);
|
Bird.prototype = Object.create(Animal.prototype);
|
||||||
```
|
```
|
||||||
|
|
||||||
Remember that the `prototype` is like the "recipe" for creating an object. In a way, the recipe for `Bird` now includes all the key "ingredients" from `Animal`.
|
Recuerda que el prototipo `prototype` es como la "receta" para crear un objeto. En cierto modo, la receta de `Bird` ahora incluye todos los "ingredientes" clave de `Animal`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
let duck = new Bird("Donald");
|
let duck = new Bird("Donald");
|
||||||
duck.eat(); // prints "nom nom nom"
|
duck.eat();
|
||||||
```
|
```
|
||||||
|
|
||||||
`duck` inherits all of `Animal`'s properties, including the `eat` method.
|
`duck` hereda todas las propiedades de `Animal`, incluyendo el método `eat`.
|
||||||
|
|
||||||
# --instructions--
|
# --instructions--
|
||||||
|
|
||||||
Modify the code so that instances of `Dog` inherit from `Animal`.
|
Modifica el código para que las instancias de `Dog` hereden de `Animal`.
|
||||||
|
|
||||||
# --hints--
|
# --hints--
|
||||||
|
|
||||||
`Dog.prototype` should be an instance of `Animal`.
|
`Dog.prototype` debe ser una instancia de `Animal`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(Animal.prototype.isPrototypeOf(Dog.prototype));
|
assert(Animal.prototype.isPrototypeOf(Dog.prototype));
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
id: 587d7db2367417b2b2512b8a
|
id: 587d7db2367417b2b2512b8a
|
||||||
title: >-
|
title: >-
|
||||||
Use Closure to Protect Properties Within an Object from Being Modified Externally
|
Utiliza closures para evitar que las propiedades de un objeto se puedan modificar desde fuera
|
||||||
challengeType: 1
|
challengeType: 1
|
||||||
forumTopicId: 18234
|
forumTopicId: 18234
|
||||||
dashedName: >-
|
dashedName: >-
|
||||||
@ -10,50 +10,49 @@ dashedName: >-
|
|||||||
|
|
||||||
# --description--
|
# --description--
|
||||||
|
|
||||||
In the previous challenge, `bird` had a public property `name`. It is considered public because it can be accessed and changed outside of `bird`'s definition.
|
En el desafío anterior, `bird` tenía una propiedad pública `name`. Se considera pública porque se puede acceder y cambiar fuera de la definición de `bird`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
bird.name = "Duffy";
|
bird.name = "Duffy";
|
||||||
```
|
```
|
||||||
|
|
||||||
Therefore, any part of your code can easily change the name of `bird` to any value. Think about things like passwords and bank accounts being easily changeable by any part of your codebase. That could cause a lot of issues.
|
Por lo tanto, cualquier parte de tu código puede cambiar fácilmente el nombre "name" de `bird` a cualquier valor. Piensa en cosas como contraseñas y cuentas bancarias que se pueden cambiar fácilmente por cualquier parte de tu base de código. Eso podría crear muchos problemas.
|
||||||
|
|
||||||
The simplest way to make this public property private is by creating a variable within the constructor function. This changes the scope of that variable to be within the constructor function versus available globally. This way, the variable can only be accessed and changed by methods also within the constructor function.
|
La forma más sencilla de hacer privada esta propiedad pública es creando una variable dentro de la función constructora. Esto cambia el alcance de esa variable para que esté dentro de la función constructora versus disponible globalmente. De este modo, la variable solo puede ser accesible y cambiable por métodos que también estén dentro de la función constructora.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
function Bird() {
|
function Bird() {
|
||||||
let hatchedEgg = 10; // private variable
|
let hatchedEgg = 10;
|
||||||
|
|
||||||
/* publicly available method that a bird object can use */
|
|
||||||
this.getHatchedEggCount = function() {
|
this.getHatchedEggCount = function() {
|
||||||
return hatchedEgg;
|
return hatchedEgg;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
let ducky = new Bird();
|
let ducky = new Bird();
|
||||||
ducky.getHatchedEggCount(); // returns 10
|
ducky.getHatchedEggCount();
|
||||||
```
|
```
|
||||||
|
|
||||||
Here `getHatchedEggCount` is a privileged method, because it has access to the private variable `hatchedEgg`. This is possible because `hatchedEgg` is declared in the same context as `getHatchedEggCount`. In JavaScript, a function always has access to the context in which it was created. This is called `closure`.
|
Aquí `getHatchedEggCount` es un método privilegiado, porque tiene acceso a la variable privada `hatchedEgg`. Esto es posible porque `hatchedEgg` está declarada en el mismo contexto que `getHatchedEggCount`. En JavaScript, una función siempre tiene acceso al contexto en el que se creó. A esto se le llama `closure`.
|
||||||
|
|
||||||
# --instructions--
|
# --instructions--
|
||||||
|
|
||||||
Change how `weight` is declared in the `Bird` function so it is a private variable. Then, create a method `getWeight` that returns the value of `weight` 15.
|
Cambia como `weight` es declarada en la función `Bird` para que sea una variable privada. Después, crea un método `getWeight` que devuelva el valor 15 para `weight`.
|
||||||
|
|
||||||
# --hints--
|
# --hints--
|
||||||
|
|
||||||
The `weight` property should be a private variable and should be assigned the value of `15`.
|
La propiedad `weight` debe ser una variable privada y debe asignársele el valor `15`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(code.match(/(var|let|const)\s+weight\s*\=\s*15\;?/g));
|
assert(code.match(/(var|let|const)\s+weight\s*\=\s*15\;?/g));
|
||||||
```
|
```
|
||||||
|
|
||||||
Your code should create a method in `Bird` called `getWeight` that returns the value of the private variable `weight`.
|
Tu código debe crear un método llamado `getWeight` en `Bird` que devuelva el valor de la variable privada `weight`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(new Bird().getWeight() === 15);
|
assert(new Bird().getWeight() === 15);
|
||||||
```
|
```
|
||||||
|
|
||||||
Your `getWeight` function should return the private variable `weight`.
|
Tu función `getWeight` debe devolver la variable privada `weight`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(code.match(/((return\s+)|(\(\s*\)\s*\=\>\s*))weight\;?/g));
|
assert(code.match(/((return\s+)|(\(\s*\)\s*\=\>\s*))weight\;?/g));
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
id: 587d7db0367417b2b2512b83
|
id: 587d7db0367417b2b2512b83
|
||||||
title: Use Inheritance So You Don't Repeat Yourself
|
title: Usa herencia para que no te repitas
|
||||||
challengeType: 1
|
challengeType: 1
|
||||||
forumTopicId: 301334
|
forumTopicId: 301334
|
||||||
dashedName: use-inheritance-so-you-dont-repeat-yourself
|
dashedName: use-inheritance-so-you-dont-repeat-yourself
|
||||||
@ -8,9 +8,9 @@ dashedName: use-inheritance-so-you-dont-repeat-yourself
|
|||||||
|
|
||||||
# --description--
|
# --description--
|
||||||
|
|
||||||
There's a principle in programming called <dfn>Don't Repeat Yourself (DRY)</dfn>. The reason repeated code is a problem is because any change requires fixing code in multiple places. This usually means more work for programmers and more room for errors.
|
Hay un principio en la programación llamado <dfn>No te repitas (Don't Repeat Yourself "DRY")</dfn>. La razón por la que el código repetido es un problema es porque cualquier tipo de cambio requiere corregir código en múltiples lugares. Esto suele significar más trabajo para los programadores y más espacio para errores.
|
||||||
|
|
||||||
Notice in the example below that the `describe` method is shared by `Bird` and `Dog`:
|
Observa en el siguiente ejemplo como el método `describe` es compartido por `Bird` y `Dog`:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
Bird.prototype = {
|
Bird.prototype = {
|
||||||
@ -28,7 +28,7 @@ Dog.prototype = {
|
|||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
The `describe` method is repeated in two places. The code can be edited to follow the DRY principle by creating a `supertype` (or parent) called `Animal`:
|
El método `describe` se repite en dos lugares. El código se puede editar para seguir el principio DRY creando un `supertype` (o padre) llamado `Animal`:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
function Animal() { };
|
function Animal() { };
|
||||||
@ -41,7 +41,7 @@ Animal.prototype = {
|
|||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
Since `Animal` includes the `describe` method, you can remove it from `Bird` and `Dog`:
|
Dado que `Animal` incluye el método `describe`, puedes eliminarlo de `Bird` y `Dog`:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
Bird.prototype = {
|
Bird.prototype = {
|
||||||
@ -55,23 +55,23 @@ Dog.prototype = {
|
|||||||
|
|
||||||
# --instructions--
|
# --instructions--
|
||||||
|
|
||||||
The `eat` method is repeated in both `Cat` and `Bear`. Edit the code in the spirit of DRY by moving the `eat` method to the `Animal` `supertype`.
|
El método `eat` se repite tanto en `Cat` como `Bear`. Edita el código utilizando el principio DRY, moviendo el método `eat` al `supertype` `Animal`.
|
||||||
|
|
||||||
# --hints--
|
# --hints--
|
||||||
|
|
||||||
`Animal.prototype` should have the `eat` property.
|
`Animal.prototype` debe tener la propiedad `eat`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(Animal.prototype.hasOwnProperty('eat'));
|
assert(Animal.prototype.hasOwnProperty('eat'));
|
||||||
```
|
```
|
||||||
|
|
||||||
`Bear.prototype` should not have the `eat` property.
|
`Bear.prototype` no debe tener la propiedad `eat`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(!Bear.prototype.hasOwnProperty('eat'));
|
assert(!Bear.prototype.hasOwnProperty('eat'));
|
||||||
```
|
```
|
||||||
|
|
||||||
`Cat.prototype` should not have the `eat` property.
|
`Cat.prototype` no debe tener la propiedad `eat`.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
assert(!Cat.prototype.hasOwnProperty('eat'));
|
assert(!Cat.prototype.hasOwnProperty('eat'));
|
||||||
|
Reference in New Issue
Block a user