Files
freeCodeCamp/curriculum/challenges/espanol/02-javascript-algorithms-and-data-structures/basic-javascript/modify-array-data-with-indexes.md
camperbot 0432ec995f chore(i18n,learn): processed translations (#41387)
* chore(i8n,learn): processed translations

* fix: remove extra space

Co-authored-by: Nicholas Carrigan (he/him) <nhcarrigan@gmail.com>

Co-authored-by: Crowdin Bot <support+bot@crowdin.com>
Co-authored-by: Randell Dawson <5313213+RandellDawson@users.noreply.github.com>
Co-authored-by: Nicholas Carrigan (he/him) <nhcarrigan@gmail.com>
2021-03-07 08:15:14 -08:00

87 lines
1.5 KiB
Markdown

---
id: cf1111c1c11feddfaeb8bdef
title: Modifica los datos de un arreglo con índices
challengeType: 1
videoUrl: 'https://scrimba.com/c/czQM4A8'
forumTopicId: 18241
dashedName: modify-array-data-with-indexes
---
# --description--
A diferencia de las cadenas, las entradas de los arreglos son <dfn>mutables</dfn> y pueden cambiarse libremente.
**Ejemplo**
```js
var ourArray = [50,40,30];
ourArray[0] = 15;
```
`ourArray` ahora tiene el valor `[15, 40, 30]`.
**Nota:** No debe haber espacios entre el nombre del arreglo y los corchetes, como `array [0]`. Aunque JavaScript pueda procesar esto correctamente, puedes confundir a otros programadores al leer tu código.
# --instructions--
Modifica los datos almacenados en el índice `0` de `myArray` a un valor de `45`.
# --hints--
`myArray` ahora debe ser `[45,64,99]`.
```js
assert(
(function () {
if (
typeof myArray != 'undefined' &&
myArray[0] == 45 &&
myArray[1] == 64 &&
myArray[2] == 99
) {
return true;
} else {
return false;
}
})()
);
```
Debes usar el índice correcto para modificar el valor en `myArray`.
```js
assert(
(function () {
if (code.match(/myArray\[0\]\s*=\s*/g)) {
return true;
} else {
return false;
}
})()
);
```
# --seed--
## --after-user-code--
```js
if(typeof myArray !== "undefined"){(function(){return myArray;})();}
```
## --seed-contents--
```js
// Setup
var myArray = [18,64,99];
// Only change code below this line
```
# --solutions--
```js
var myArray = [18,64,99];
myArray[0] = 45;
```