<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>if...else</title> <script type="text/JavaScript"> var mymoney,sum=0;//mymoney变量存放不同面值,sum总计 for(mymoney=1;mymoney<=10;mymoney++) { sum1= sum + mymoney; } document.write("sum合计:"+sum1+"<br /><br />"); </script> </head> <body> </body> </html>
1+2+3+4+5+6+7+8+9=45