fix(curriculum): Made output for sample code in snippet clearer - Multidimensional Array Access (#47222)

* Made output for sample code in snippet clearer

* Made formatting more consistent

* Fixed names for formatting fix
This commit is contained in:
mjh
2022-08-09 13:39:56 -07:00
committed by GitHub
parent 441815b72a
commit ab82857ab2

View File

@@ -21,12 +21,13 @@ const arr = [
[[10, 11, 12], 13, 14]
];
arr[3];
arr[3][0];
arr[3][0][1];
const subarray = arr[3];
const nestedSubarray = arr[3][0];
const element = arr[3][0][1];
```
`arr[3]` is `[[10, 11, 12], 13, 14]`, `arr[3][0]` is `[10, 11, 12]`, and `arr[3][0][1]` is `11`.
In this example, `subarray` has the value `[[10, 11, 12], 13, 14]`,
`nestedSubarray` has the value `[10, 11, 12]`, and `element` has the value `11` .
**Note:** There shouldn't be any spaces between the array name and the square brackets, like `array [0][0]` and even this `array [0] [0]` is not allowed. Although JavaScript is able to process this correctly, this may confuse other programmers reading your code.