Multi-dimensional arrays in many languages are just arrays within arrays.
// Create an array with 4 elements.
var b = [1, [2, 3], [4, [5, 6], 7], 8];
console.log(b.length); // 4
// Looping through arrays
for(var i=0; i<b.length; i++){
// b[0] = 1
// b[1] = [2, 3]
// b[2] = [4, Array[2], 7]
// b[3] = 8
console.log("b["+i+"] =", b[i]);
}
// Since b[1] is an array, ...
console.log(b[1][0]); // First element in [2, 3], which is 2
// We can go deeper.
console.log(b[2][1]); // [5, 6]
console.log(b[2][1][0]); // 5
// We can change entries, of course.
b[2][1][0] = 42;
console.log(b[2][1][0]); // 42
b[1] = ['a', 'b', 'c'];
console.log(b[1][0]); // "a"
Therefore, making a 3 by 3 matrix can be done like this:
var b = [];
for(var i=0; i<3; i++){
b[i] = [];
for(var j=0; j<3; j++){
b[i][j] = prompt("b["+(i+1)+","+(j+1)+"] = ?");
}
}
(Of course, this is not the best way to do, but it is the easiest way to follow.)