Basic Data Structures - Create complex multi-dimensional arrays

I am trying to understand the nested arrays and how to index into them. It states that nestedArray[2][1][0][0][0] is how you would index into ‘deepest-est?’ . However I don’t understand where the final [0] comes from.

I highlighted the nested arrays in the following image, and I don’t get why nestedArray[2][1][0][0] does not index to ‘deepest est?’. Can anyone please explain where the final [0] comes from? I would appreciate any help.

Challenge: Basic Data Structures - Create complex multi-dimensional arrays

Link to the challenge:

1 Like

Hi Travis

You did well, you just add an extra [0] to your code. It should be:

nestedArray[2][1][0][0]

I hope it helps, happy coding and keep the good work! :sunglasses:

P.S. Some times what we need is just take a break and rest, it is important.

1 Like

Hey carlosvisator, sorry but I am still confused. freeCodeCamp says it should be nestedArray [2][1][0][0][0]. I think it should be nestedArray[2][1][0][0]. Are you saying what I think it should be is correct?

Also thank you for helping!

Try pasting that example array code in the editor and use the console.log(nestedArray[2][1][0][0][0]) and add and remove that last [0] and see if you can understand whay you need that extra [0]. Would [2][1][0][0] get you the string ‘deepest-est?’, or would it just be an array holding that string?

2 Likes

Hi Travis

Sorry, with my code you access to the array it self

[ 'deepest-est?' ]

And then with extra [0]… you know already, right?

You could put some random items inside every array in that example. I think that will be helpful to better understanding the code. Examples too simple sometimes are not good for better understanding.

Keep this tool in your browser as well, it is helpful to visualize JavaScript.

https://pythontutor.com/visualize.html#mode=edit

I hope that make more sense.

Happy code!

1 Like

Perfect I get what I was missing. Thank you for the help and for the tip to figure out future roadblocks that I run into :slight_smile: Thank you carolsvisator too!!

2 Likes

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