实例
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>九九乘法表</title> </head> <body> <script> for (i = 1; i <= 9; i++) { for (j = 1; j <= 9; j++) { document.write(i + "x" + j + "=" + i * j + " "); if (i == j) { document.write("<br/>"); break; } } } //星号三角 for (i = 0; i < 10; i++) { for (j = 0; j < 10 - i; j++) { document.write(" "); } for (n = 0; n < 1 + (i * 2); n++) { document.write("*"); } document.write("<br>"); } var i = 1; var j = 1; while (i <= 5) { j = 1; while (j <= i) { document.write("*"); j++; } document.write("<br>"); i++; } </script> </body> </html>
运行实例 »
点击 "运行实例" 按钮查看在线实例