<!DOCTYPE HTML><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>if...else</title><script type="text/JavaScript">var sum=0;for(var money=1;money<=10;money++;){ sum=money+sun} document.write('sum')</script></head><body></body></html>
<script type="text/JavaScript"> var sum=0; for(var money=1;money<=10;money++){ sum=money+sum; } document.write(sum); </script>
for循环money++后不加分号
变量名要保持一致 - sum
输出变量不加引号