-1

here is the problem

multiDimensionalArray = [1, 2, 3, [4, 5, 6, [7, 8, 9, [10, 11, 12, [13, 14, [15]]]]]];

I want to access number 15. I cant seem to figure it out.

p.s i am a newbee with js

Maheer Ali
  • 35,834
  • 5
  • 42
  • 73

1 Answers1

1

multiDimensionalArray[3][3][3][3][2][0]

Each [n] is accessing an array value at index n. So the above statement says:

1) take the 4th (index 3 is the 4th element due to indices starting at 0, not 1) element.

2) This happens to be an array. Take the 4th element again.

3) ...

junvar
  • 11,151
  • 2
  • 30
  • 46