问答详情
源自:7-23 编程练习

错误在哪里呢

var mydate=new Date();  var year=mydate.getFullYear();  var month=mydate.getMonth();  var weekday=["周日","周一","周二","周三","周四","周五","周六"];  var num=mydate.getDay();  document.write(year+month+weekday[num]); 为什么我这个显示不出来,求指导错误~谢谢

提问者:hellocy64 2016-05-23 19:45

个回答

  • JPlin
    2016-05-23 21:09:59

    var weekday=["周日","周一","周二","周三","周四","周五","周六"];

    这句话中的逗号和分号用错了,你使用的都是中文字符的标点符号,应改成英文的标点符号。

    还有

    document.write(year+month+weekday[num]);

    改成:

    document.write(year+"年"+month+"月"+ weekday[num]);

  • 空城盼故人
    2016-05-23 21:08:19

     var weekday=["周日","周一","周二","周三","周四","周五","周六"];//这一行的标点符号错了,应该是英文状态下的


  • 抬头那片丿天
    2016-05-23 21:02:23

    +只能连接字符串吧