<script type="text/javascript"> var mydate = new Date(); var timestr = ''; timestr = mydate.getFullYear()+"年"; timestr += mydate.getMonth()+1+"月"; timestr += mydate.getData()+"日"; var day = mydate.getDay(); var week = ''; switch(day){ case 0: week = '星期日'; break; case 1: week = '星期一'; break; case 2: week = '星期二'; break; case 3: week = '星期三'; break; case 4: week = '星期四'; break; case 5: week = '星期五'; break; case 6: week = '星期六'; break; } timestr += " "+week; document.write(timestr); var arrstr = "小明:87; 小花:81; 小红:97; 小天:76;小张:74;小小:94;小西:90;小伍:76;小迪:64;小曼:76"; var arr = arrstr.split(";"); var sum = 0; var av = 0; for (var i = 0; i < arr.length; i++) { var index = arr[i].indexOf(":"); var a = parseInt(arr[i].substr(index+1,2)); sum += a; } av = sum/arr.length; document.write("--班级总分为:"+av); </script>
第六行粗心 应该是mydate.getDate()
日期显示那句话改了 ,+是连接符不是累加的意思