while循环 九九乘法表
实例
<!DOCTYPE html> <html> <head> <title>hello world!</title> </head> <body> <script type="text/javascript"> var a=1; while(a<=9){ var b=1; while(b<=a){ document.write(b+'X'+a+'='+(a*b)+' '); b++ } a++ document.write('<br>'); } </script> </body> </html>
运行实例 »
点击 "运行实例" 按钮查看在线实例
while循环三角形
实例
<!DOCTYPE html> <html> <head> <title>hello world!</title> </head> <body> <script type="text/javascript"> var a=1; while(a<=10){ var b=1; while(b<=a){ document.write('*'); b++ } a++ document.write('<br>'); } </script> </body> </html>
运行实例 »
点击 "运行实例" 按钮查看在线实例