二位数组的输入输出
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <script language="JavaScript" type="text/jscript"> var arr = [ [1, 2, 4, 6], [2, 4, 7, 8], [8, 9, 10, 11], [9, 12, 13, 15] ]; for(var i = 0; i < arr.length; i++) { for(var j = 0; j < arr[i].length; j++) { document.write(arr[i][j]); } document.write("<br/>"); } </script> </head> <body> </body> </html>
开始老是错误的代码:
为啥错误?将docunent.write 写作 window.write 应该是window.alert();
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <script language="JavaScript" type="text/jscript"> // 多维数组 var arr = [ ["shunping", 1, 2, 3], ["dashe", 1, 1] ]; // var arr = [ // [1, 2, 4, 6], // [2, 4, 7, 8], // [8, 9, 10, 11], // [9, 12, 13, 15] // ]; for(var i = 0; i < arr.length; i++) { for(var j = 0; j < arr[i].length; j++) { document.write(arr[i][j]); } document.write("<br/>"); } </script> </head> <body> </body> </html>