为了账号安全,请及时绑定邮箱和手机立即绑定

练习题交作业

<!DOCTYPE  HTML>

<html >

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>系好安全带,准备启航</title>

<script type="text/javascript">

  //通过javascript的日期对象来得到当前的日期,并输出。

  var mydate=new Date();

  var year=mydate.getFullYear();

  var month=mydate.getMonth()+1;

  var date=mydate.getDate();

  var week=['星期日','星期一','星期二','星期三','星期四','星期五','星期六']

  var mynum=mydate.getDay();

  document.write(year+'年'+month+'月'+date+'日'+'&nbsp;'+week[mynum]+"<br/>");

  //成绩是一长窜的字符串不好处理,找规律后分割放到数组里更好操作哦

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

  var person=scoreStr.split(";");

  var sum=0;

  for(var i=0;i<person.length;i++){

     sum += parseInt(person[i].slice(3));

  }

  //从数组中将成绩撮出来,然后求和取整,并输出。

  document.write("班级总分:"+sum+"<br/>");

  document.write("班级平均分:"+ Math.round(sum/(person.length+1)));

</script>

</head>

<body>

</body>

</html>


正在回答

2 回答

后者是父类引用指向自己的子类

https://www.61bcx.com/scratch3/work/926903https://www.61bcx.com/scratch3/work/938601https://www.61bcx.com/scratch3/work/937105https://www.61bcx.com/scratch3/work/927128https://www.61bcx.com/scratch3/work/933785https://www.61bcx.com/scratch3/work/931424https://www.61bcx.com/scratch3/work/934822https://www.61bcx.com/scratch3/work/930367https://www.61bcx.com/scratch3/work/932451https://www.61bcx.com/scratch3/work/944812https://www.61bcx.com/scratch3/work/928996https://www.61bcx.com/scratch3/work/926594https://www.61bcx.com/scratch3/work/947495https://www.61bcx.com/scratch3/work/939302https://www.61bcx.com/scratch3/work/938868https://minecraft.fandom.com/zh/wiki/UserProfile:%E8%80%81%E8%A1%97%E6%96%B0%E7%99%BE%E8%83%9C%E5%A8%B1%E4%B9%90%E5%9F%8E%E7%94%B5%E8%AF%9D%E5%AE%98%E7%BD%91TL262%EF%BC%8E%EF%BC%A3%EF%BC%AF%EF%BC%AD%E6%BB%A8%E5%B7%9E%E4%BA%BA%E6%89%8D%E7%BD%91%EF%BF%A5%EF%BC%A7?variant=zh-hk&cb=&mobileaction=toggle_view_mobilehttps://www.fastsoso.cc/search?k=%E7%8E%89%E7%A5%A5%E5%A8%B1%E4%B9%90%E5%9C%A8%E5%93%AA%E9%87%8C%E5%BE%AE%E4%BF%A1%E5%BC%80%E6%88%B7%E7%94%B5%E8%AF%9D%E3%80%90TL262%C2%B7%EF%BC%A3%EF%BC%AF%EF%BC%AD%E6%AC%A2%E8%BF%8E%E6%82%A8%E3%80%91%E8%BE%BD%E9%98%B3%E5%88%86%E7%AB%99http://www.vpansou.com/query?wd=%E9%BB%91%E9%BE%99%E6%B1%9F%E5%8F%8C%E5%9F%8E%E5%93%AA%E6%9C%89%E7%BD%91%E4%B8%8A%E5%B9%B3%E5%8F%B0%E5%AE%98%E7%BD%91B2024%C2%B7CN%E6%B4%9B%E9%98%B3%E5%88%86%E7%AB%99%EF%BC%85https://iias.tsinghua.edu.cn/search/%E6%9E%9C%E5%8D%9A%E4%B8%9C%E6%96%B9%E9%BE%99%E8%99%8E%E8%B5%8C%E8%B5%99%E7%BD%91%E7%AB%99%E6%8E%A8%E8%8D%90B2024%C2%B7CN%E6%BB%81%E5%B7%9E%E7%99%BE%E5%A7%93%E7%BD%91/feed/rss/https://www.oschina.net/search?scope=news&q=%E9%94%A6%E5%88%A9%E5%9B%BD%E9%99%85%E4%B8%8B%E5%88%86%E6%8F%90%E6%AC%BE%E7%9B%B4%E8%90%A5%E5%BC%80%E6%88%B7%3AB2024.CN%E9%98%9C%E6%96%B0%E8%81%94%E9%80%9A&days=0&onlytitle=0&sort_by_time=0https://mod.3dmgame.com/mods?mods_title=%E7%BC%85%E7%94%B8%E9%BE%99%E6%BA%90%E5%9B%BD%E9%99%85%E7%BC%85%E7%94%B8%E9%BE%99%E6%BA%90%E5%A8%B1%E4%B9%90%E3%80%90TL262%C2%B7C%EF%BC%AFM%E3%80%91%E8%81%8A%E5%9F%8E%E7%96%AB%E6%83%85http://biz.finance.sina.com.cn/zjzt/more.php?lytype=ipoly_hyxdly&title=%C0%CF%BD%D6%BB%CA%BC%D2%B9%FA%BC%CA%D7%DC%BB%E3%B5%E7%BB%B0%B9%D9%CD%F8TL262%A1%A4C%A3%CFM%B3%B2%BA%FE%D1%A7%B8%AE%A3%D9%A3%CC%A3%A4http://biz.finance.sina.com.cn/zjzt/more.php?lytype=ipoly_hyxdly&title=%C3%E5%B5%E9%BB%AA%C4%C9%B9%FA%BC%CA%D3%E9%C0%D6%D2%F4%C0%D6%BF%AA%BB%A7%B9%D9%CD%F8TL262%A1%A4C%A3%CFM%B9%E3%D4%AA%C8%CB%B2%C5%CD%F8%A3%F9%A3%A1%A3%ADhttps://db.auto.sina.com.cn/search/?search_txt=%E7%8E%89%E5%92%8C%E6%8F%90%E7%8E%B0%E5%BF%AB%E4%B8%8D%E5%BF%AB%E7%BD%91%E5%9D%80B2024%C2%B7CN%E5%B9%BF%E5%B7%9E%E5%A4%A7%E5%AD%A6%EF%BC%BDhttps://wap.zol.com.cn/index.php?c=List_List&keyword=%E6%96%B0%E7%99%BE%E8%83%9C%E5%A8%B1%E4%B9%90%E5%AE%98%E6%96%B9%E7%BD%91%E7%AB%99%E7%82%B9%E5%87%BB%E5%8F%B0%E6%8E%A8%E8%8D%90TL262%C2%B7C%EF%BC%AFM%E6%97%A5%E7%85%A7%E5%AD%A6%E5%BA%9Chttp://house.china.com.cn/sousou/%25101%253D%252C%2520%25BA%25FE%25C4%25CF%25CF%25E6%25CF%25E7%25D5%25E6%25C8%25CB%25C6%25BD%25CC%25A8%25BF%25AA%25BB%25A7%25B9%25D9%25CD%25F8TL262%25A1%25A4C%25A3%25CFM%252C%25D3%25A5%25CC%25B6%25D2%25BD%25B1%25A3%25A3%25CF%25A3%25C3%25A3%25D8_1s.htmhttps://mod.3dmgame.com/mods?mods_title=%E6%96%B0%E7%99%BE%E8%83%9C%E5%A8%B1%E4%B9%90%E5%AE%A2%E6%9C%8D%E5%9C%A8%E7%BA%BF%E7%8E%B0%E5%9C%BATL262%C2%B7C%EF%BC%AFM%E6%B3%B0%E5%AE%89%E7%BE%8E%E9%A3%9Fhttps://www.fastsoso.cc/search?k=%E7%9A%87%E5%AE%B6%E5%88%A9%E5%8D%8E%E5%BC%80%E6%88%B7%E5%AE%98%E7%BD%91B2024%EF%BC%8E%EF%BC%A3N%E6%A0%AA%E6%B4%B2%E7%83%AD%E6%90%9C%EF%BC%9A%EF%BD%9Chttp://biz.finance.sina.com.cn/zjzt/more.php?lytype=ipoly_hyxdly&title=%C0%CF%BD%D6%CC%DA%C1%FA%B9%FA%BC%CA%BC%AF%CD%C5%D4%F5%C3%B4%CF%C2%D4%D8%A1%BE%B9%D9%CD%F8%A1%FATL262%A1%A4%A3%C3%A3%CF%A3%CD%A1%BF%CC%C6%C9%BD%C6%F3%D2%B5%A3%FC%A3%CDhttps://list.jd.com/search?keyword=%E7%BC%85%E5%8C%97%E9%91%AB%E7%99%BE%E5%88%A9%E5%A8%B1%E4%B9%90%E5%9F%8E%E5%AE%98%E6%96%B9%E7%BD%91%E5%9D%80B2024.CN%E5%B9%B3%E5%8F%B0%E5%BC%80%E6%88%B7http://www.vpansou.com/query?wd=%E5%AE%89%E5%BE%BD%E5%90%88%E8%82%A5%E5%93%AA%E6%9C%89%E7%BD%91%E4%B8%8A%E5%B9%B3%E5%8F%B0%E3%80%90B2024%C2%B7CN%E3%80%91%E9%B9%A4%E5%B2%97%E6%AF%95%E4%B8%9A%E7%94%9F

0 回复 有任何疑惑可以回复我~
几个小建议:
1.获取日期,获取成绩可以分成两个函数分开写;
2.可以写一个formatNum的函数,将小于10的月份和日子转为01、02……09的格式;
3.person[i].slice(3)这边可以继续使用split(":")进行分割;
4.parseInt函数最好还是使用第二个参数,比如这里parseInt(person[i].slice(3), 10)表示10进制,否则eslint规范会报错;
5.Math.round(sum/(person.length+1))这里应该是person.length,而不是length+1。


0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
JavaScript进阶篇
  • 参与学习       463866    人
  • 解答问题       21818    个

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

进入课程

练习题交作业

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信