音客
<script type="text/javascript">
var mydate = new Date();
var myweek = ["星期日","星期一","星期二","星期三","星期四","星期五","星期六",]
//通过javascript的日期对象来得到当前的日期,并输出。
var yearStr = mydate.getFullYear()+"年";
var monthStr = mydate.getMonth()+1+"月";
var dateStr = mydate.getDate()+"日";
var weekStr = myweek[mydate.getDay()];
document.write(yearStr+monthStr+dateStr+" "+weekStr);
//成绩是一长窜的字符串不好处理,找规律后分割放到数组里更好操作哦
var scoreStr = "小明:87;小花:81;小红:97;小天:76;小张:74;小小:94;小西:90;小伍:76;小迪:64;小曼:76";
var scorenum = scoreStr.split(";");
//从数组中将成绩撮出来,然后求和取整,并输出。
var score = new Array();
for (var i=0;i<scorenum.length;i++){
score[i] = scorenum[i].substr(3);
}
var total =0;
for (var n=0;n<score.length;n++){
total = total + parseInt(score[n]);
}
document.write("<br />班级总分为:"+total+"、<br />班级平均分为(保留整数):"+Math.round(total/score.length));