ASDV-WebDev/Semester 1/Chapter ZIPs/JavaScript/ch8/ex_8_16.html

28 lines
546 B
HTML

<html>
<head>
<title>Example 8.16</title>
<script type="text/javascript">
var myarray = new Array(6); //allocates 6 rows to the array
for (i = 0; i < 6; i++)
{
myarray[i] = new Array(5); //allocates 5 columns each row
}
document.write("Ex 8.16: 2-D array: <br />");
for (var i = 0; i < 6; i++)
{
for (var j = 0; j < 5; j++)
{
myarray[i][j] = prompt("Enter value for row " + i + ", column " + j +":");
document.write(myarray[i][j] + " ");
}
document.write("<br />");
}
</script>
</head>
<body>
</body>
</html>