<script type="text/javascript"> var mydate=new Date(); var year=mydate.getFullYear(); var month=mydate.getMonth(); var day=mydate.getDate(); var weekday=["日","一","二","三","四","五","六"]; var num=mydate.getDay(); var week=weekday[num]; var scoreStr = "小明:87;小花:81;小红:97;小天:76;小张:74;小小:94;小西:90;小伍:76;小迪:64;小曼:76"; var sourceArr = sorceStr.split(";"); var sum=0; for(i=0;i<=sourceArr.length;i++){ sum=sum+parseInt(sourceArr[i].slice(3,5)); } function a(){ document.write("今天时间是 :"+year+"年"+month+"月"+day+"日"+"今天是周"+week+"该班级总分是:"+sum+"该班级平均分是:"+parseInt(sum/sourceArr.length)); //从数组中将成}绩撮出来,然后求和取整,并输出。 } </script> <input type="button" value="点击我" onclick="a()" />
李晓健
yohoho
相关分类