chore(i18n,learn): processed translations (#41424)
* chore(i8n,learn): processed translations * Update curriculum/challenges/chinese/01-responsive-web-design/applied-visual-design/use-the-u-tag-to-underline-text.md Co-authored-by: Randell Dawson <5313213+RandellDawson@users.noreply.github.com> Co-authored-by: Crowdin Bot <support+bot@crowdin.com> Co-authored-by: Nicholas Carrigan (he/him) <nhcarrigan@gmail.com> Co-authored-by: Randell Dawson <5313213+RandellDawson@users.noreply.github.com>
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d7b8e367417b2b2512b5e
|
||||
title: Avoid Mutations and Side Effects Using Functional Programming
|
||||
title: Evita mutaciones y efectos secundarios utilizando programación funcional
|
||||
challengeType: 1
|
||||
forumTopicId: 301228
|
||||
dashedName: avoid-mutations-and-side-effects-using-functional-programming
|
||||
@ -8,39 +8,39 @@ dashedName: avoid-mutations-and-side-effects-using-functional-programming
|
||||
|
||||
# --description--
|
||||
|
||||
If you haven't already figured it out, the issue in the previous challenge was with the `splice` call in the `tabClose()` function. Unfortunately, `splice` changes the original array it is called on, so the second call to it used a modified array, and gave unexpected results.
|
||||
Si aún no te has dado cuenta, el problema en el desafío anterior estaba en la llamada `splice` de la función `tabClose()`. Desafortunadamente, `splice` modifica el arreglo original a la que se llama, por lo que la segunda llamada a ella utilizo un arreglo modificado, y dio resultados inesperados.
|
||||
|
||||
This is a small example of a much larger pattern - you call a function on a variable, array, or an object, and the function changes the variable or something in the object.
|
||||
Este es un pequeño ejemplo de un patrón mucho mayor: se llama a una función en una variable, arreglo o un objeto, y la función modifica la variable o algo en el objeto.
|
||||
|
||||
One of the core principles of functional programming is to not change things. Changes lead to bugs. It's easier to prevent bugs knowing that your functions don't change anything, including the function arguments or any global variable.
|
||||
Uno de los principios fundamentales de la programación funcional es no cambiar las cosas. Los cambios conducen a errores. Es más fácil evitar errores sabiendo que las funciones no cambian nada, incluyendo los argumentos de la función o cualquier variable global.
|
||||
|
||||
The previous example didn't have any complicated operations but the `splice` method changed the original array, and resulted in a bug.
|
||||
El ejemplo anterior no tenía operaciones complicadas, pero el método `splice` modificó el arreglo original y dio como resultado en un error.
|
||||
|
||||
Recall that in functional programming, changing or altering things is called <dfn>mutation</dfn>, and the outcome is called a <dfn>side effect</dfn>. A function, ideally, should be a <dfn>pure function</dfn>, meaning that it does not cause any side effects.
|
||||
Recuerda que en la programación funcional, cambiar o alterar cosas se denomina <dfn>mutación</dfn>, y el resultado es conocido como <dfn>efecto secundario</dfn>. Una función, idealmente, debe ser una <dfn>función pura</dfn>, lo que significa que no provoca ningún efecto secundario.
|
||||
|
||||
Let's try to master this discipline and not alter any variable or object in our code.
|
||||
Intentemos dominar esta disciplina y no alterar ninguna variable u objeto en nuestro código.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Fill in the code for the function `incrementer` so it returns the value of the global variable `fixedValue` increased by one.
|
||||
Completa el código de la función `incrementer` para que devuelva el valor de la variable global `fixedValue` incrementada en uno.
|
||||
|
||||
# --hints--
|
||||
|
||||
Your function `incrementer` should not change the value of `fixedValue` (which is `4`).
|
||||
Tu función `incrementer` no debe cambiar el valor de `fixedValue` (que es `4`).
|
||||
|
||||
```js
|
||||
incrementer();
|
||||
assert(fixedValue === 4);
|
||||
```
|
||||
|
||||
Your `incrementer` function should return a value that is one larger than the `fixedValue` value.
|
||||
La función `incrementer` debe devolver el valor de `fixedValue` más uno.
|
||||
|
||||
```js
|
||||
const __newValue = incrementer();
|
||||
assert(__newValue === 5);
|
||||
```
|
||||
|
||||
Your `incrementer` function should return a value based on the global `fixedValue` variable value.
|
||||
La función `incrementer` debe devolver un valor basado en el valor de la variable global `fixedValue`.
|
||||
|
||||
```js
|
||||
(function () {
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
id: 587d7b8f367417b2b2512b62
|
||||
title: Implement map on a Prototype
|
||||
title: Implementa map en un prototipo
|
||||
challengeType: 1
|
||||
forumTopicId: 301230
|
||||
dashedName: implement-map-on-a-prototype
|
||||
@ -8,25 +8,25 @@ dashedName: implement-map-on-a-prototype
|
||||
|
||||
# --description--
|
||||
|
||||
As you have seen from applying `Array.prototype.map()`, or simply `map()` earlier, the `map` method returns an array of the same length as the one it was called on. It also doesn't alter the original array, as long as its callback function doesn't.
|
||||
Como has visto anteriormente, al aplicar `Array.prototype.map()`, o simplemente `map()`, el método `map` devuelve un arreglo de la misma longitud que el arreglo dentro del que fue llamado. Esto tampoco altera el arreglo original, siempre y cuando su función callback no lo haga.
|
||||
|
||||
In other words, `map` is a pure function, and its output depends solely on its inputs. Plus, it takes another function as its argument.
|
||||
En otras palabras, `map` es una función pura, y su salida depende únicamente de sus entradas. Además, toma otra función como argumento.
|
||||
|
||||
You might learn a lot about the `map` method if you implement your own version of it. It is recommended you use a `for` loop or `Array.prototype.forEach()`.
|
||||
Puedes aprender mucho sobre el método `map` si implementas tu propia versión. Se recomienda utilizar un bucle `for` o `Array.prototype.forEach()`.
|
||||
|
||||
# --instructions--
|
||||
|
||||
Write your own `Array.prototype.myMap()`, which should behave exactly like `Array.prototype.map()`. You should not use the built-in `map` method. The `Array` instance can be accessed in the `myMap` method using `this`.
|
||||
Escribe tu propio `Array.prototype.myMap()`, el cual debe comportarse exactamente como `Array.prototype.map()`. No debes utilizar el método incorporado `map`. Se puede acceder a la instancia de `Array` en el método `myMap` usando `this`.
|
||||
|
||||
# --hints--
|
||||
|
||||
`new_s` should equal `[46, 130, 196, 10]`.
|
||||
`new_s` debe ser igual a `[46, 130, 196, 10]`.
|
||||
|
||||
```js
|
||||
assert(JSON.stringify(new_s) === JSON.stringify([46, 130, 196, 10]));
|
||||
```
|
||||
|
||||
Your code should not use the `map` method.
|
||||
Tu código no debe utilizar el método `map`.
|
||||
|
||||
```js
|
||||
assert(!code.match(/\.?[\s\S]*?map/g));
|
||||
|
Reference in New Issue
Block a user