search

Home  >  Q&A  >  body text

没明白赋值的时候 sum=0 和 输出的时候+sum 的意思?

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


checkcheck2913 days ago1159

reply all(2)I'll reply

  • 数据分析师

    数据分析师2017-09-30 23:34:55

    Don’t understand the meaning of sum=0 when assigning values ​​and +sum when outputting? -PHP Chinese website Q&A-Don’t understand the meaning of sum=0 when assigning values ​​and +sum when outputting? -PHP Chinese website Q&A

    Please watch and learn.

    reply
    0
  • 迷茫

    迷茫2016-12-22 14:00:22

    最开始的sum=0是给sum初始化,+sum是+前的内容和sum的值合并成一个string

    reply
    0
  • Cancelreply