<!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++;)
{
sum= sum + mymoney;
}
document.write("sum合计:"+sum);
</script>
</head>
<body>
</body>
</html>
for(mymoney=1;mymoney<=10; mymoney++)
删掉最后一个分号
for循环的条件,最后一个分号不要写!注意细节!共勉!
for循环的条件for(mymoney=1;mymoney<=10; mymoney++;)分号不要写
for(mymoney=1;mymoney<=10; mymoney++;)
这句代码mymoney++后面多写了个“;”,删掉就可以
for(mymoney=1;mymoney<=10; mymoney++;)
删除最后一个分号