1let x = [
2 [1, 2, 3],
3 [4, 5, 6],
4 [7, 8, 9]
5];
6console.log(items[0][0]); // 1
7console.log(items[0][1]); // 2
8console.log(items[1][0]); // 4
9console.log(items[1][1]); // 5
10console.log(items);
1// program to create a two dimensional array
2
3function twoDimensionArray(a, b) {
4 let arr = [];
5
6 // creating two dimensional array
7 for (let i = 0; i< a; i++) {
8 for(let j = 0; j< b; j++) {
9 arr[i] = [];
10 }
11 }
12
13 // inserting elements to array
14 for (let i = 0; i< a; i++) {
15 for(let j = 0; j< b; j++) {
16 arr[i][j] = j;
17 }
18 }
19 return arr;
20}
21
22const x = 2;
23const y = 3;
24
25const result = twoDimensionArray(x, y);
26console.log(result);
1var x = new Array(10);
2
3for (var i = 0; i < x.length; i++) {
4 x[i] = new Array(3);
5}
6
7console.log(x);