亲测已成功!
var mysum=0,
scoreA = new Array(),
scoreStr = "小明:87;小花:81;小红:97;小天:76;小张:74;小小:94;小西:90;小伍:76;小迪:64;小曼:76",
len = scoreStr.length,
date = new Date(),
y = date.getFullYear(),
mth = date.getMonth() + 1,
day = date.getDate(),
week = date.getDay();
switch (week) {
case 0: week = '日'
break;
case 1: week = '一'
break;
case 2: week = '二'
break;
case 3: week = '三'
break;
case 4: week = '四'
break;
case 5: week = '五'
break;
case 6: week = '六'
break;
}
document.write(scoreStr.length + '<br/>');
for (var i = 3; i < len; i += 6) {
scoreA.push(scoreStr.slice(i, i + 2));
}
console.log(scoreA)
for (var j = 0; j < scoreA.length; j++) {
mysum = mysum + parseInt(scoreA[j]);
}
document.write(y + '年' + mth + '月' + day + '日' + ' ' + '星期' + week + '- -' + '班级总分为:' + mysum);