手记

JavaScript进阶篇(7-23)代码

<!DOCTYPE  HTML>
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>系好安全带,准备启航</title>
<script type="text/javascript">
    var date1= new Date();
    var week1=['日','一','二','三','四','五','六'];
    document.write(
        date1.getFullYear()+"年"+
        (date1.getMonth()+1)+"月"+
        date1.getDate()+"日"+" 星期"+
        week1[date1.getDay()]+"- -班级总分为:"
        );
    var scoreStr = "小明:87;小花:81;小红:97;小天:76;小张:74;小小:94;小西:90;小伍:76;小迪:64;小曼:76";
    var sum=0;
    var temp=0;
    for(var i=3;i<scoreStr.length;i=i+6)
    {
        sum=sum+parseInt(scoreStr.substr(i,2));
        temp++;
    }
    document.write(Math.floor(sum/temp));
</script>
</head>
<body>
</body>
</html>
1人推荐
随时随地看视频
慕课网APP