- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <TITLE>我的FOR迴圈</TITLE>
- </head>
- <body>
- <script type="text/javascript">
- var start = parseInt(prompt("起始數字:"));
- var end = parseInt(prompt("數字:"));
- var total=0;
- for(var a=start<=end; a++)
- {
- total=a+ total;
- document. write(a+"|"+total);
- document. write("<br />");
- }
- alert("總共是");
- </script>
- </body>
- </html>
複製代碼 |