为什么没有结果输出
为什么运行没有结果显示
为什么运行没有结果显示
2019-04-11
<!DOCTYPE HTML>
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>系好安全带,准备启航</title>
<script type="text/javascript">
var week=["星期天","星期一","星期二","星期三","星期四","星期五","星期六"];
var mydate=new Date();
document.write(mydate.getFullYear()+"年"+(mydate.getMonth()+1)+"月"+mydate.getDate()+"日"+" "+week[mydate.getDay()]+"--班级总分为:");
var scoreStr = "小明:87;小花:81;小红:97;小天:76;小张:74;小小:94;小西:90;小伍:76;小迪:64;小曼:76";
var str=scoreStr.split(";");
var sum=0;
for(var i=0;i<str.length;i++){
sum+=parseInt(str[i].substring(3,5));
}
document.write(Math.floor(sum/10));
</script>
</head>
<body>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>系好安全带,准备启航</title>
<script type="text/javascript">
week = [
"星期日",
"星期一",
"星期二",
"星期三",
"星期四",
"星期五",
"星期六"
];
var mydate = new Date();
document.write(mydate.getFullYear()+"年"+mydate.getMonth()+"月"+mydate.getDay()+"日"+" " + week[mydate.getDay()]+"--");
var scoreStr =
"小明:87;小花:81;小红:97;小天:76;小张:74;小小:94;小西:90;小伍:76;小迪:64;小曼:76";
var myarr = scoreStr.split(";");
var sum = 0;
for (var i = 0; i < myarr.length; i++) {
sum = sum + parseInt(myarr[i].slice(3));
}
document.write("班级总分为:" + sum+"<br />");
document.write("班级平均分为:" + Math.round(sum/myarr.length)+"<br />");
</script>
</head>
<body></body>
</html>
<script type="text/javascript">
var mydate =new Date();
document.write("今天是"+" "+mydate.getFullYear()+"年"+(mydate.getMonth()+1)+"月"+mydate.getDate()+"日");
//通过javascript的日期对象来得到当前的日期,并输出。
var weekday = ["星期日","星期一","星期二","星期三","星期四","星期五","星期六"];
var mynum = mydate.getDay();
document.write(" "+weekday[mynum]+"<br>");
var scoreStr = "小明:87;小花:81;小红:97;小天:76;小张:74;小小:94;小西:90;小伍:76;小迪:64;小曼:76";
scoreStr = scoreStr.split(';');
var score =[
scoreStr[0].slice(3,5),
scoreStr[1].slice(3,5),
scoreStr[2].slice(3,5),
scoreStr[3].slice(3,5),
scoreStr[4].slice(3,5),
scoreStr[5].slice(3,5),
scoreStr[6].slice(3,5),
scoreStr[7].slice(3,5),
scoreStr[8].slice(3,5),
scoreStr[9].slice(3,5)
];
console.log(score);
var sum = 0;
for( var i =0; i < score.length;i++){
sum += parseInt(score[i]);
}
console.log(sum);
var avg = sum / score.length;
document.write("该班的平均分为:"+avg);
//成绩是一长窜的字符串不好处理,找规律后分割放到数组里更好操作哦
//从数组中将成绩撮出来,然后求和取整,并输出。
<!DOCTYPE HTML>
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>系好安全带,准备启航</title>
<script type="text/javascript">
//通过javascript的日期对象来得到当前的日期,并输出。
var yihzou = ['星期天','星期一','星期二','星期三','星期四','星期五','星期六'];
var scoreStr = "小明:87;小花:81;小红:97;小天:76;小张:74;小小:94;小西:90;小伍:76;小迪:64;小曼:76";
var time = new Date();
var year = time.getFullYear();
var month = time.getMonth()+1;
var day = time.getDate();
var xingqi = time.getDay();
var fenge = scoreStr.split(';');
var sum = 0;
for (var i = 0; i <= fenge.length-1; i++) {
var j = parseInt(fenge[i].substr(3));
sum = sum+j;
}
document.write(year+'年'+month+'月'+day);
document.write(yihzou[xingqi]+'--班级总分为:'+sum);
</script>
</head>
<body>
</body>
</html>
举报