--- id: 56592a60ddddeae28f7aa8e1 title: Access Multi-Dimensional Arrays With Indexes challengeType: 1 guideUrl: 'https://chinese.freecodecamp.org/guide/certificates/access-array-data-with-indexes' videoUrl: '' localeTitle: 访问带索引的多维数组 --- ## Description
考虑多维数组的一种方法是作为数组的数组 。使用括号访问数组时,第一组括号引用最外层(第一级)数组中的条目,另外一对括号引用内部的下一级条目。
var arr = [
[1,2,3],
[4,5,6]
[7,8,9]
[[10,11,12],13,14]
]。
ARR [3]; //等于[[10,11,12],13,14]
ARR [3] [0]; //等于[10,11,12]
ARR [3] [0] [1]; //等于11
注意
数组名称和方括号之间不应该有任何空格,如array [0][0] ,甚至不允许使用此array [0] [0] 。尽管JavaScript能够正确处理,但这可能会让其他程序员在阅读代码时感到困惑。
## Instructions
使用括号表示法从myArray选择一个元素,使myData等于8
## Tests
```yml tests: - text: myData应该等于8 。 testString: 'assert(myData === 8, "myData should be equal to 8.");' - text: 您应该使用括号表示法从myArray读取正确的值。 testString: 'assert(/myArray\[2\]\[1\]/g.test(code) && !/myData\s*=\s*(?:.*[-+*/%]|\d)/g.test(code), "You should be using bracket notation to read the correct value from myArray.");' ```
## Challenge Seed
```js // Setup var myArray = [[1,2,3], [4,5,6], [7,8,9], [[10,11,12], 13, 14]]; // Only change code below this line. var myData = myArray[0][0]; ```
### After Test
```js console.info('after the test'); ```
## Solution
```js // solution required ```