In Example 1, we have manually populated each storage location in the array. Instead we can use to 2 nested for loops as shown below.

var myArray1 = new
Array(3)

for (i = 0; i < 3; i++)

myArray1[i] = new Array(3)

var start = 1;

for (var i = 0; i < 3; i++)

{

for (var j =
0; j < 3; j++)

{

myArray1[i][j] = start;

start = start + 1;

}

}

for (var i = 0; i < 3; i++)

{

for (var j =
0; j < 3; j++)

{

document.write(myArray1[i][j]
+ "&emsp;");

}

document.write("<br/>");

}

Performing addition between 2 two dimensional arrays in JavaScript

Example : a) The first 3 x 3 array should contain numbers from 1 to 9b) The second 3 x 3 array should contain numbers from 9 to 1c) The numbers present at each index position in the first and second array should be added and the result should be stored in a third 3x3 array.