用JS的for循环打印九九乘法表
需要使用两个for循环嵌套,代码如下:
1 <!DOCTYPE html> 2 <html lang="en"> 3 <head> 4 <meta charset="UTF-8"> 5 <title>九九乘法表</title> 6 </head> 7 <body> 8 <script> 9 for (var i =1 ; i <= 9; i++) { 10 for(var j=1; j<=i; j++){ 11 document.write(i+'x'+j+'='+i*j+','); 12 } 13 document.write('<br/>'); 14 } 15 </script> 16 </body> 17 </html>