亲测已成功!

来源:7-23 编程练习

慕运维9098251

2018-12-30 13:30

var mysum=0,

scoreA = new Array(),

scoreStr = "小明:87;小花:81;小红:97;小天:76;小张:74;小小:94;小西:90;小伍:76;小迪:64;小曼:76",

len = scoreStr.length,

date = new Date(),

y = date.getFullYear(),

mth = date.getMonth() + 1,

day = date.getDate(),

week = date.getDay();

switch (week) {

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;

}

document.write(scoreStr.length + '<br/>');

for (var i = 3; i < len; i += 6) {

scoreA.push(scoreStr.slice(i, i + 2));

}

console.log(scoreA)

for (var j = 0; j < scoreA.length; j++) {

mysum = mysum + parseInt(scoreA[j]);

}

document.write(y + '年' + mth + '月' + day + '日' + ' ' + '星期' + week + '- -' + '班级总分为:' + mysum);


写回答 关注

1回答

  • 一只傻吴笛
    2019-01-01 19:46:15

    看别的同学的笔记就好

JavaScript进阶篇

本课程从如何插入JS代码开始,带您进入网页动态交互世界

468061 学习 · 21891 问题

查看课程

相似问题