星期几阵列

时间:2014-12-09 13:40:39

标签: javascript arrays

var days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
var birthDate = new Date(year, monthNumber/3, day);
var dayNumber = (birthDate.getDay());
var dayName = days.indexOf(dayNumber);
document.writeln ('I was born on a ' + dayName + '');{

为什么要赢得这项工作?它输出-1对我来说,var daynumber是正确的,显示正确的日期编号,但是如何让它对应/输出实际的日期名称?

1 个答案:

答案 0 :(得分:0)

这将有效:

var dayName = days[dayNumber];