+ 1
The date object result gives Friday and undefined
Friday and undefined is the result. Why is it not Friday alone? function main() { var year = parseInt(readLine(), 10); var month = parseInt(readLine(), 10); var day = parseInt(readLine(), 10); var daysName = this.day; console.log(getWeekDay(year, month, day)) } function getWeekDay(year, month, day) { var names = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]; var d = new Date(year, month, day); //complete the function var i = d.getDay(); var daysName = names[i]; console.log(daysName); }
2 odpowiedzi
+ 4
function getWeekDay isn't returning anything yet you are using console.log on it. Simply call the function otherwise it will print undefined if no value is returned by the function.
+ 2
Thank you Abhay!