大神救救孩子吧,var persons=scoreStr.split(";");这行为什么要赋值到persons,还有后面那个.split(";")是什么意思?
<script type="text/javascript">
var date=new Date();
var year=date.getFullYear();
var mouth=date.getMonth()+1;
var day=date.getDate();
var days=date.getDay();
var weekday=["星期日","星期一","星期二","星期三","星期四","星期五","星期六"];
var formatday=year+"年"+mouth+"月"+day+"日---"+weekday[days];
document.write(formatday+"<br/>");
var scoreStr = "小明:87;小花:81;小红:97;小天:76;小张:74;小小:94;小西:90;小伍:76;小迪:64;小曼:76";
var persons=scoreStr.split(";");
var num=0;
for(var i=0;i<persons.length;i++){
var a=persons[i].split(":");
document.write(a[0]+"的成绩为:"+a[1]+"<br />"); //实现每个人成绩的输出
num=num+parseInt(a[1]); // 累加总分
}
document.write("总分:"+num+"<br/>");
document.write("平均分:"+Math.round(num/persons.length));
</script>