感觉写复杂了
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
//获取日期
var taday = new Date();
var weekday = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"]
let time = taday.getDay();
let timeWeek = weekday[time];
let timeYear = taday.getFullYear();
let timeMonth = taday.getMonth();
let timeDate = taday.getDate();
//成绩平均值
var scoreStr = "小明:87;小花:81;小红:97;小天:76;小张:74;小小:94;小西:90;小伍:76;小迪:64;小曼:76";
let arr = new Array();
arr = scoreStr.split(";")
var count = 0;
var num2 = 0;
for (var i = 0; i < arr.length; i++) {
var num = Number(arr[i].substring(3, 5));
num2 += num;
count++;
}
var b = parseInt(num2 / count);
document.write(timeYear + "年" + timeMonth + "月" + timeDate + "日" + " " + timeWeek + "--班级总分数为:" + b);
</script>
</body>
</html>