0
How to solve this problem date Object using Node js
Sample Input 1993 7 12 Sample Output Thursday function main() { var year = parseInt(readLine(), 10); var month = parseInt(readLine(), 10); var day = parseInt(readLine(), 10); //the output console.log(getWeekDay(year, month, day)); } function getWeekDay(year, month, day){ var weekDayNames = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]; //complete the function return weekDayNames }
2 Respuestas
+ 2
ABDORIZAK ABDALLA Your getWeekDay function could be like this:
function getWeekDay(year, month, day) {
const days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
return days[new Date(year, month, day)
.getDay()]
}