One way to think of a multi-dimensional array, is as an array of arrays. 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.Exampleconst 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];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.Using bracket notation select an element from myArray such that myData is equal to 8.Run the Tests (Ctrl + Enter)Reset this lessonGet HelpTestsWaiting:myData should be equal to 8.Waiting:You should be using bracket notation to read the correct value from myArray.
Question
One way to think of a multi-dimensional array, is as an array of arrays. 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.Exampleconst 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];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.Using bracket notation select an element from myArray such that myData is equal to 8.Run the Tests (Ctrl + Enter)Reset this lessonGet HelpTestsWaiting:myData should be equal to 8.Waiting:You should be using bracket notation to read the correct value from myArray.
Solution
The text you provided is a JavaScript tutorial on how to access elements in a multi-dimensional array. To make myData equal to 8, you need to know the position of 8 in your array.
Assuming myArray is the same as arr in the example, 8 is located in the third array at the second position. In JavaScript, arrays are zero-indexed, meaning the first position is 0, the second position is 1, and so on.
So, to access 8, you would use the following code:
let myData = myArray[2][1];
This code first accesses the third array with myArray[2] and then accesses the second element in that array with [1]. The result, 8, is then stored in the myData variable.
Similar Questions
What do you mean by the terms “Dimension” and “Subscript” when we talk about arrays?
One-dimensional array is also known as _____________AVectorBNdarrayCMatriksDSubscript
what is an array
In C++, a one-dimensional array inside a one-dimensional array is called _________.
In C/C++ language, the subscript of array starts from ______.
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.