堇延未七
2016-05-09 14:15:59浏览 2801
<script type="text/javascript">
var curDate = new Date();
var year = curDate.getFullYear();
var month = curDate.getMonth()+1;
var day = curDate.getDate();
var weekday = curDate.getDay();
if(weekday != 0){
weekday = "星期"+weekday;
}else{
weekday = "星期日";
}
document.write(year+"年"+month+"月"+day+"日"+" "+weekday);
var scoreStr = "小明:87;小花:81;小红:97;小天:76;小张:74;小小:94;小西:90;小伍:76;小迪:64;小曼:76";
var scoreArr = scoreStr.split(";");
var scores = new Array();
var sum = 0,aver = 0;
for(var i in scoreArr){
//将转化后的数组中的成绩取出来,并转化为Int型
scores[i] = parseInt(scoreArr[i].substr(scoreArr[i].indexOf(":")+1));
}
for(var i in scores){
sum = sum+scores[i];
}
aver = sum/scores.length;
document.write("--"+"班级平均分为:"+Math.floor(aver));
</script>