不见长安似水
2019-03-18 20:31
var mynum=new Array();
for(var i=0;i<3;i++){
mynum[i]=new Array();
for(j=0;j<6;j++){
mynum[i][j]=i*j;
}
}
document.write(mynum);
如上我想把结果按照每行六个共三行输出该怎么写?
<!DOCTYPE HTML> <html > <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>流程控制语句</title> <script type="text/javascript"> var mynum=new Array(); for(var i=0;i<3;i++){ mynum[i]=new Array(); for(j=0;j<6;j++){ mynum[i][j]=i*j; } } document.write(mynum[0]+"<br>"+mynum[1]+"<br>"+mynum[2]+"<br>"); </script> </head> <body> </body> </html>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>二维数组</title>
<script type="text/javascript">
var myarr= new Array();
for(var i=0;i<3;i++){
myarr[i]=new Array();
for(var j=0;j<6;j++){
myarr[i][j]=i*j;
if(j<5){
document.write(myarr[i][j]+" ");
}
else{
document.write(myarr[i][j]+"<br>");
}
}
}
</script>
</head>
<body>
</body>
</html>
JavaScript进阶篇
468061 学习 · 21891 问题
相似问题