1.9 KiB
id, title, challengeType, videoUrl, forumTopicId, dashedName
| id | title | challengeType | videoUrl | forumTopicId | dashedName |
|---|---|---|---|---|---|
| 56592a60ddddeae28f7aa8e1 | Accede a arreglos multidimensionales con índices | 1 | https://scrimba.com/c/ckND4Cq | 16159 | access-multi-dimensional-arrays-with-indexes |
--description--
Se puede pensar que un arreglo multidimensional es como un arreglo de arreglos. When you use brackets to access your array, the first set of brackets refers to the entries in the outermost (the first level) array, and each additional pair of brackets refers to the next level of entries inside.
Ejemplo
const arr = [
[1, 2, 3],
[4, 5, 6],
[7, 8, 9],
[[10, 11, 12], 13, 14]
];
const subarray = arr[3];
const nestedSubarray = arr[3][0];
const element = arr[3][0][1];
En este ejemplo, subarray tiene el valor [[10, 11, 12], 13, 14], nestedSubarray tiene el valor [10, 11, 12], y element tiene el valor 11.
Nota: No debe haber ningún espacio entre el nombre del arreglo y los corchetes, ni array [0][0] o array [0] [0] están permitidos. Aunque JavaScript pueda procesar esto correctamente, puedes confundir a otros programadores al leer tu código.
--instructions--
Usa la notación de corchetes para seleccionar un elemento de myArray de tal manera que myData sea igual a 8.
--hints--
myData debe ser igual a 8.
assert(myData === 8);
Debes usar notación de corchetes para leer el valor correcto de myArray.
assert(/myData=myArray\[2\]\[1\]/.test(__helpers.removeWhiteSpace(code)));
--seed--
--after-user-code--
if(typeof myArray !== "undefined"){(function(){return "myData: " + myData + " myArray: " + JSON.stringify(myArray);})();}
--seed-contents--
const myArray = [
[1, 2, 3],
[4, 5, 6],
[7, 8, 9],
[[10, 11, 12], 13, 14],
];
const myData = myArray[0][0];
--solutions--
const myArray = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [[10, 11, 12], 13, 14]];
const myData = myArray[2][1];