hello every body,
I anyone can help me with this issue?
I have created this array and i would like to access the index 15 and save it in to new variable called fifteen.
var myArray = [1, 2, 3, [4, 5, 6, [7, 8, 9, [10, 11, 12, [13, 14, [15]]]]]];
well, i need to use array indexing to access the number 15 in myArray and assign it to a variable called fifteen. then the indexes that were required to access the number 15, i should create a one-dimensional array called indxArray which contains, in order, the array indices i used to access the number 15 in the fifteen variable.
You do not need to create any additional arrays. You just need to reference that applicable index, based on the depth of the element in the various nested elements.
Example:
If I had have a two-dimensional array (below):
const array = [
[3, 4], [16, 18, 19]
]
If I want to reference the number 18, I would write: