1.6 KiB
1.6 KiB
id, title, challengeType, videoUrl, forumTopicId, dashedName
id | title | challengeType | videoUrl | forumTopicId | dashedName |
---|---|---|---|---|---|
cf1111c1c11feddfaeb8bdef | Modifica los datos de un arreglo con índices | 1 | https://scrimba.com/c/czQM4A8 | 18241 | modify-array-data-with-indexes |
--description--
A diferencia de las cadenas, las entradas de los arreglos son mutables y pueden cambiarse libremente, incluso si el arreglo fue declarado con const
.
Ejemplo
const 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]
.
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
.
assert(
(function () {
if (code.match(/myArray\[0\]\s*=\s*/g)) {
return true;
} else {
return false;
}
})()
);
--seed--
--after-user-code--
if(typeof myArray !== "undefined"){(function(){return myArray;})();}
--seed-contents--
// Setup
const myArray = [18, 64, 99];
// Only change code below this line
--solutions--
const myArray = [18, 64, 99];
myArray[0] = 45;