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 }

18th Apr 2021, 6:34 PM
ABDORIZAK ABDALLA
ABDORIZAK ABDALLA - avatar
1 Resposta
+ 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()] }
18th Apr 2021, 7:08 PM
CamelBeatsSnake
CamelBeatsSnake - avatar