To create a two dimensional array in JavaScript, we put arrays inside an array.
For instance, we write
const items = [
[1, 2],
[3, 4],
[5, 6],
];
console.log(items[0][0]);
console.log(items[0][1]);
console.log(items[1][0]);
console.log(items[1][1]);
to put arrays inside the items
array.
Then we access the first array in item
‘s items with
console.log(items[0][0]);
console.log(items[0][1]);
We access the 2nd array in item
‘s items with
console.log(items[1][0]);
console.log(items[1][1]);