Multidimensional Array

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]]]]]];

thanks in advance

@Asifd Welcome to the forum!

Have a look at this curriculum challenge. Then try to write some more code and post it if you still can not figure out how to solve.

This array does not have any arrays with an element at index 15. Did you mean you would like to access the value 15 in the array?

yes and then save that in to a variable called fifteen

how do you think that should happen?
what method/feature/syntax do you think should be used?

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.

are those the instructions of this task? you need to create an array with the indexes?

you have not answered my question tho, what syntax do you need to use with the indexes?

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.


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:


Do you understand why?

Thank you for your comment. yes I do understand that. lets i try that

See my corrected reply above. You may have to refresh the page to see it.

1 Like

i am very much beginner with the programming. just started programming… i was stucked with an exercise and trying to solve it and to know it better

It may be you need a different training program. Have you tried starting with the Basic JavaScript curriculum of Free Code Camp?

no not yet. i just joint today and try to look at it later

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.