凑够五个字
var d = new Date();
var m = d.getMonth() + 1;
var str = "星期" + "日一二三四五六".charAt(new Date().getDay());
document.write(d.getFullYear() + "年" + m + "月" + d.getDate() + "日" + " " + str);
<!DOCTYPE HTML>
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>系好安全带,准备启航</title>
<script type="text/javascript">
var mydate = new Date();
var week = ["星期日","星期一","星期二","星期三","星期四","星期五","星期六"];
var a = mydate.getDay();
document.write(mydate.getFullYear() + "年" + (mydate.getMonth()+1) + "月" + mydate.getDate() + "日" + " " + week[a] + "--");
var scoreStr = "小明:87;小花:81;小红:97;小天:76;小张:74;小小:94;小西:90;小伍:76;小迪:64;小曼:76";
var arr = scoreStr.split(";");
var sum = 0;
for(var i=0;i<arr.length;i++){
sum += parseInt(arr[i].substring(3));// sum += parseInt(arr[i].substring(arr[i].indexOf(":")+1));
}
var avgScore = sum / arr.length;
document.write("班级平均分为:" + Math.round(avgScore));
</script>
</head>
<body>
</body>
</html>
老哥我看到你答案的时候我都惊了!!!!!!!!!!!!
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>成绩打印</title>
<script>
var myDate = new Date();
var weekday = ["星期日","星期一","星期二","星期三","星期四","星期五","星期六"];
var myWeek = myDate.getDay();
var myYear = myDate.getFullYear();
var myMonth =myDate.getMonth();
var soStr = "小明:87; 小花:81; 小红:97; 小天:76;小张:74;小小:94;小西:90;小伍:76;小迪:64;小曼:76";
var scoreStr = soStr.split(';');
var cont = 0;
for(i = 0;i<scoreStr.length;i++){
var score = scoreStr[i].indexOf(':');
cont += parseInt( scoreStr[i].substr(score+1,2) );
};
document.write(myYear+"年"+myMonth+'月'+myWeek+'日'+" "+weekday[myWeek]+"--"+"班级平均分为:"+Math.floor(cont/scoreStr.length))
</script>
</head>
<body>
</body>
</html>
我们的好像差不多一样。