I need to know how to work with a 2D Array and nested loop.
This is the code that I have so far -
var x = parseInt(window.prompt("inter the row:"));
var y = parseInt(window.prompt("inter the column:"));
var [,]names = new Array[x,y];
for (var i=0; i<x;i++)
{
for(var j=0; j<y;j++)
{
names [i,j]=parseInt(window.prompt(" "));
}
}
for (var i=0; i<x;i++)
{
for(var j=0; j<y;j++)
{
document.write(names[i,j]);
}
document.write("<br>");
}
This code does not work, and I need help figuring out what might be wrong with it.