Basic JavaScript - Access Multi-Dimensional Arrays With Indexes

Tell us what’s happening:

Describe your issue in detail here.
Greetings fellow Coders,

What’s the easiest way of understanding “ARRAYS”???
I’m doing the “Basic JavaScript”, and its honestly showing me flames.
I keep reading the instructions, over and over again, but I’m still stuck.
I took multiple breaks, and came back to retry, but still get stuck.
What might I be doing wrong? Because I do comprehend English.
Or maybe it’s the numbers that are puzzling me?
I Desperately need to understand JavaScript.
I could copy and paste puzzling lessons, but I would be doing injustice to my self, if I pass, but completely don’t understand.
Please HELP.

Your code so far

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

const myData = myArray[1][1];
console.log(myData)

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

const myData = myArray[0][0];

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36

Challenge Information:

Basic JavaScript - Access Multi-Dimensional Arrays With Indexes

You appear to have created this post without editing the template. Please edit your post to Tell us what’s happening in your own words.

As you carry on with the curriculum and as you work with more arrays you’ll grasp the concepts, don’t worry.
Now back to your question, one thing you should take note of is that arrays have a zero-based index, which means that instead of starting at 1, we start at 0, like, 0,1,2,3… Let me structure an example for you.

let arrayOne = [
  [1, 2, 3],
  [4, 5, 6],
  [7, 8, 9]
];
 [ 1, 2, 3]  this array starts at index 0
 [4, 5, 6] this array starts at index 1
 [7, 8, 9] this array starts at index 2

 [ 1, 2, 3]...... 1, in this array starts at index 0, 2 at index 1 and 3 at index 2;

So if you want to select 2 in the above array, you’ll use this syntax.
arrayOne[main array index][inner array index]

arrayOne[0][1]; will output 2 

I hope I answered your question, if you encounter some difficulties, kindly let me know for further clarity.

2 Likes

I understand now. Thank you

1 Like

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