本周我的Javascript任务涉及Date对象。到目前为止,我已经完成了以下工作并且有效:
var monthArray = new Array("January", "February", "March", "April", "May", "June", "July",
"August", "September", "October", "November", "December");
var weekDaysArray =new Array("Sun", "Mon", "Tues", "Weds", "Thurs", "Fri");
var reqMonth = prompt("Please enter the number of the month you want to display");
reqMonth = parseInt(reqMonth);
var todaysDate = new Date();
var currYr = todaysDate.getFullYear();
var currMon = todaysDate.getMonth();
var currDate = todaysDate.getDate();
var currDay = todaysDate.getDay();
while((reqMonth == null)||(reqMonth > 12))
{
reqMonth = prompt("Please enter a number between 1 and 12, corresponding with the month you want to display");
reqMonth = parseInt(reqMonth);
}
document.write((currMon + 1) + "/" + currDate + "/" + currYr +
"<br />" + "<br />" + monthArray[reqMonth-1] + " " + currYr);
这是事情变得困难的地方,至少对我来说,其余的任务是:
最终输出如下: 2014年11月21日(当前日期) 2014年11月(从提示中选择的月份)
Week 1 of November
Sat 1
Week 2 of November
Sun 2
Mon 3
Tue 4
等......直到该月的所有日子都会显示出来。
我是否会使用我已经指示执行第6步的Date对象?还是另外一个?