chore(i8n,learn): processed translations (#41462)
Co-authored-by: Crowdin Bot <support+bot@crowdin.com>
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d7da9367417b2b2512b6a
|
||||
title: Return a Sorted Array Without Changing the Original Array
|
||||
title: Devuelve un arreglo ordenado sin cambiar el arreglo original
|
||||
challengeType: 1
|
||||
forumTopicId: 301237
|
||||
dashedName: return-a-sorted-array-without-changing-the-original-array
|
||||
@ -8,27 +8,27 @@ dashedName: return-a-sorted-array-without-changing-the-original-array
|
||||
|
||||
# --description--
|
||||
|
||||
A side effect of the `sort` method is that it changes the order of the elements in the original array. In other words, it mutates the array in place. One way to avoid this is to first concatenate an empty array to the one being sorted (remember that `slice` and `concat` return a new array), then run the `sort` method.
|
||||
Un efecto secundario del método `sort` es que cambia el orden de los elementos en el arreglo original. En otras palabras, muta el arreglo en su sitio. Una forma de evitar esto es concatenar primero un arreglo vacío al que está siendo ordenado (recuerda que `slice` y `concat` devuelven un nuevo arreglo), luego ejecutar el método `sort`.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Use the `sort` method in the `nonMutatingSort` function to sort the elements of an array in ascending order. The function should return a new array, and not mutate the `globalArray` variable.
|
||||
Utiliza el método `sort` en la función `nonMutatingSort` para ordenar los elementos de un arreglo en orden ascendente. La función debe devolver un nuevo arreglo y no mutar la variable `globalArray`.
|
||||
|
||||
# --hints--
|
||||
|
||||
Your code should use the `sort` method.
|
||||
Tu código debe usar el método `sort`.
|
||||
|
||||
```js
|
||||
assert(nonMutatingSort.toString().match(/\.sort/g));
|
||||
```
|
||||
|
||||
The `globalArray` variable should not change.
|
||||
La variable `globalArray` no debe cambiar.
|
||||
|
||||
```js
|
||||
assert(JSON.stringify(globalArray) === JSON.stringify([5, 6, 3, 2, 9]));
|
||||
```
|
||||
|
||||
`nonMutatingSort(globalArray)` should return `[2, 3, 5, 6, 9]`.
|
||||
`nonMutatingSort(globalArray)` debe devolver `[2, 3, 5, 6, 9]`.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -37,18 +37,32 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
`nonMutatingSort(globalArray)` should not be hard coded.
|
||||
`nonMutatingSort(globalArray)` no debe ser programada manualmente.
|
||||
|
||||
```js
|
||||
assert(!nonMutatingSort.toString().match(/[23569]/g));
|
||||
```
|
||||
|
||||
The function should return a new array, not the array passed to it.
|
||||
La función debe devolver un nuevo arreglo, no el arreglo que se le pasa.
|
||||
|
||||
```js
|
||||
assert(nonMutatingSort(globalArray) !== globalArray);
|
||||
```
|
||||
|
||||
`nonMutatingSort([1, 30, 4, 21, 100000])` debe devolver `[1, 4, 21, 30, 100000]`.
|
||||
|
||||
```js
|
||||
assert(JSON.stringify(nonMutatingSort([1, 30, 4, 21, 100000])) ===
|
||||
JSON.stringify([1, 4, 21, 30, 100000]))
|
||||
```
|
||||
|
||||
`nonMutatingSort([140000, 104, 99])` debe devolver `[99, 104, 140000]`.
|
||||
|
||||
```js
|
||||
assert(JSON.stringify(nonMutatingSort([140000, 104, 99])) ===
|
||||
JSON.stringify([99, 104, 140000]))
|
||||
```
|
||||
|
||||
# --seed--
|
||||
|
||||
## --seed-contents--
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d7b90367417b2b2512b65
|
||||
title: Return Part of an Array Using the slice Method
|
||||
title: Devolver parte de un arreglo mediante el método slice
|
||||
challengeType: 1
|
||||
forumTopicId: 301239
|
||||
dashedName: return-part-of-an-array-using-the-slice-method
|
||||
@ -8,29 +8,30 @@ dashedName: return-part-of-an-array-using-the-slice-method
|
||||
|
||||
# --description--
|
||||
|
||||
The `slice` method returns a copy of certain elements of an array. It can take two arguments, the first gives the index of where to begin the slice, the second is the index for where to end the slice (and it's non-inclusive). If the arguments are not provided, the default is to start at the beginning of the array through the end, which is an easy way to make a copy of the entire array. The `slice` method does not mutate the original array, but returns a new one.
|
||||
El método `slice` devuelve una copia de ciertos elementos de un arreglo. Puede tomar dos argumentos, el primero da el índice de dónde comenzar el corte, el segundo es el índice de dónde terminar el corte (y no es inclusivo). Si no se proporcionan los argumentos, el valor predeterminado es comenzar desde el principio del arreglo hasta el final, la cual es una manera fácil de hacer una copia de todo el arreglo. El método `slice` no muta el arreglo original, pero devuelve uno nuevo.
|
||||
|
||||
Here's an example:
|
||||
Por ejemplo:
|
||||
|
||||
```js
|
||||
var arr = ["Cat", "Dog", "Tiger", "Zebra"];
|
||||
var newArray = arr.slice(1, 3);
|
||||
// Sets newArray to ["Dog", "Tiger"]
|
||||
```
|
||||
|
||||
`newArray` tendría el valor de `["Dog", "Tiger"]`.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Use the `slice` method in the `sliceArray` function to return part of the `anim` array given the provided `beginSlice` and `endSlice` indices. The function should return an array.
|
||||
Utiliza el método `slice` en la función `sliceArray` para retornar parte del arreglo `anim` dados los índices `beginSlice` y `endSlice`. La función debe devolver un arreglo.
|
||||
|
||||
# --hints--
|
||||
|
||||
Your code should use the `slice` method.
|
||||
Tu código debe usar el método `slice`.
|
||||
|
||||
```js
|
||||
assert(code.match(/\.slice/g));
|
||||
```
|
||||
|
||||
The `inputAnim` variable should not change.
|
||||
La variable `inputAnim` no debe cambiar.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -39,7 +40,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
`sliceArray(["Cat", "Dog", "Tiger", "Zebra", "Ant"], 1, 3)` should return `["Dog", "Tiger"]`.
|
||||
`sliceArray(["Cat", "Dog", "Tiger", "Zebra", "Ant"], 1, 3)` debe devolver `["Dog", "Tiger"]`.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -48,7 +49,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
`sliceArray(["Cat", "Dog", "Tiger", "Zebra", "Ant"], 0, 1)` should return `["Cat"]`.
|
||||
`sliceArray(["Cat", "Dog", "Tiger", "Zebra", "Ant"], 0, 1)` debe devolver `["Cat"]`.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -57,7 +58,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
`sliceArray(["Cat", "Dog", "Tiger", "Zebra", "Ant"], 1, 4)` should return `["Dog", "Tiger", "Zebra"]`.
|
||||
`sliceArray(["Cat", "Dog", "Tiger", "Zebra", "Ant"], 1, 4)` debe devolver `["Dog", "Tiger", "Zebra"]`.
|
||||
|
||||
```js
|
||||
assert(
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d7da9367417b2b2512b69
|
||||
title: Sort an Array Alphabetically using the sort Method
|
||||
title: Ordena un arreglo alfabéticamente con el método sort
|
||||
challengeType: 1
|
||||
forumTopicId: 18303
|
||||
dashedName: sort-an-array-alphabetically-using-the-sort-method
|
||||
@ -8,9 +8,9 @@ dashedName: sort-an-array-alphabetically-using-the-sort-method
|
||||
|
||||
# --description--
|
||||
|
||||
The `sort` method sorts the elements of an array according to the callback function.
|
||||
El método `sort` ordena los elementos de un arreglo de acuerdo a la función "callback".
|
||||
|
||||
For example:
|
||||
Por ejemplo:
|
||||
|
||||
```js
|
||||
function ascendingOrder(arr) {
|
||||
@ -19,32 +19,36 @@ function ascendingOrder(arr) {
|
||||
});
|
||||
}
|
||||
ascendingOrder([1, 5, 2, 3, 4]);
|
||||
// Returns [1, 2, 3, 4, 5]
|
||||
```
|
||||
|
||||
Esto devolvería el valor de `[1, 2, 3, 4, 5]`.
|
||||
|
||||
```js
|
||||
function reverseAlpha(arr) {
|
||||
return arr.sort(function(a, b) {
|
||||
return a === b ? 0 : a < b ? 1 : -1;
|
||||
});
|
||||
}
|
||||
reverseAlpha(['l', 'h', 'z', 'b', 's']);
|
||||
// Returns ['z', 's', 'l', 'h', 'b']
|
||||
```
|
||||
|
||||
JavaScript's default sorting method is by string Unicode point value, which may return unexpected results. Therefore, it is encouraged to provide a callback function to specify how to sort the array items. When such a callback function, normally called `compareFunction`, is supplied, the array elements are sorted according to the return value of the `compareFunction`: If `compareFunction(a,b)` returns a value less than 0 for two elements `a` and `b`, then `a` will come before `b`. If `compareFunction(a,b)` returns a value greater than 0 for two elements `a` and `b`, then `b` will come before `a`. If `compareFunction(a,b)` returns a value equal to 0 for two elements `a` and `b`, then `a` and `b` will remain unchanged.
|
||||
Esto devolvería el valor de `['z', 's', 'l', 'h', 'b']`.
|
||||
|
||||
Por defecto, JavaScript ordena basándose en el valor "Unicode" de la cadena de caracteres, lo cual puede dar resultados inesperados. Por lo tanto, se recomienda proporcionar una función "callback" para especificar cómo se deben ordenar los elementos del arreglo. Cuando se proporciona dicha función "callback", normalmente llamada `compareFunction`, los elementos del arreglo se ordenan de acuerdo al valor que devuelve la función `compareFunction`: Si `compareFunction(a,b)` devuelve un valor menor a 0 para dos elementos `a` y `b`, entonces `a` irá antes que `b`. Si `compareFunction(a,b)` devuelve un valor mayor a 0 para dos elementos `a` y `b`, entonces `b` irá antes que `a`. Si `compareFunction(a,b)` devuelve un valor igual a 0 para dos elementos `a` y `b`, entonces `a` y `b` se dejarán sin cambios.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Use the `sort` method in the `alphabeticalOrder` function to sort the elements of `arr` in alphabetical order.
|
||||
Utiliza el método `sort` en la función `alphabeticalOrder` para ordenar los elementos de `arr` en orden alfabético.
|
||||
|
||||
# --hints--
|
||||
|
||||
Your code should use the `sort` method.
|
||||
Tu código debe usar el método `sort`.
|
||||
|
||||
```js
|
||||
assert(code.match(/\.sort/g));
|
||||
```
|
||||
|
||||
`alphabeticalOrder(["a", "d", "c", "a", "z", "g"])` should return `["a", "a", "c", "d", "g", "z"]`.
|
||||
`alphabeticalOrder(["a", "d", "c", "a", "z", "g"])` debe devolver `["a", "a", "c", "d", "g", "z"]`.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -53,7 +57,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
`alphabeticalOrder(["x", "h", "a", "m", "n", "m"])` should return `["a", "h", "m", "m", "n", "x"]`.
|
||||
`alphabeticalOrder(["x", "h", "a", "m", "n", "m"])` debe devolver `["a", "h", "m", "m", "n", "x"]`.
|
||||
|
||||
```js
|
||||
assert(
|
||||
@ -62,7 +66,7 @@ assert(
|
||||
);
|
||||
```
|
||||
|
||||
`alphabeticalOrder(["a", "a", "a", "a", "x", "t"])` should return `["a", "a", "a", "a", "t", "x"]`.
|
||||
`alphabeticalOrder(["a", "a", "a", "a", "x", "t"])` debe devolver `["a", "a", "a", "a", "t", "x"]`.
|
||||
|
||||
```js
|
||||
assert(
|
||||
|
Reference in New Issue
Block a user