简洁明了代码
<!DOCTYPE HTML>
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>系好安全带,准备启航</title>
<script type="text/javascript">
var date = new Date();
var year = date.getFullYear();
var mouth = date.getMonth();
var day = date.getDate();
var num = date.getDay();
switch (num){
case 0:
document.write(year+"年"+mouth+"月"+day+"日"+"星期天"+"<br>");
//偷了个懒 因为今天是周天 所以就case0了
break;
default:
break;
}
var scoreStr = "小明:87;小花:81;小红:97;小天:76;小张:74;小小:94;小西:90;小伍:76;小迪:64;小曼:76";
var a = scoreStr.split(";");
var arr1 = new Array();
arr1=a;
var arr2 = new Array();
var sum =0;
for(var i=0;i<arr1.length;i++){
arr2[i] = arr1[i].slice(-2);
sum+=parseInt(arr2[i]);
}
var aver = sum/arr2.length;
document.write("平均分为"+Math.round(aver-0.5));//直接省略小数位
</script>
</head>
<body>
</body>
</html>