mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-03-28 23:01:57 -04:00
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:
@@ -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.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user