是不是变量aver在for循环里面计算就会循环好多遍是num.length的次数?还有slice后面数字计算如何计算
var currentDate = new Date();
var weekday = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
document.write(currentDate.getFullYear()+"年"+(currentDate.getMonth()+1)+"月"+currentDate.getDate()+"日"+""+weekday[currentDate.getDay()]);
var scoreStr = "小明:87;小花:81;小红:97;小天:76;小张:74;小小:94;小西:90;小伍:76;小迪:64;小曼:76";
var num=scoreStr.split(";");
var sum=0;
var aver=0;
for(var i=0;i<num.length;i++){
sum=sum+parseInt(num[i].slice(3,5)); //数来数去不对劲
}
aver=sum/num.length;
document.write("<br/>"+"全班平均分:"+parseInt(aver));