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

这几句问题在哪里

 var mydate=new Date();
 var weekdays=["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
 document.write(mydate.getFullYear());
 document.write(mydate.getMonth());  
 document.write(mydate.getDate());
 document.write(weekdays[mydate.getDay()]);

提问者:慕粉3875660 2016-08-29 16:42

个回答

  • 沐风而来
    2016-08-29 17:09:01
    已采纳

       var mydate=new Date();

     var weekdays=["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];

     document.write(mydate.getFullYear());

     document.write(mydate.getMonth()+1);  

     document.write(mydate.getDate());

     document.write(weekdays[mydate.getDay()]);

    注意看weekdays的结束分号,是中文的!

  • qq__少傷鈊_03128626
    2016-08-29 17:19:06

    数组初始化时多了空格吧,去掉空格就好啦,var weekdays=["星期日","星期一","星期二","星期三","星期四","星期五","星期六"];

  • 慕粉wz
    2016-08-29 17:06:27

    mydate.getMonth());  

    -->

    mydate.getMonth()) +1;

    还有“年”,“月”,“日”这几个字没有输出