How to solve this problem date Object using Node js | Sololearn: Learn to code for FREE!

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 }

4/18/2021 6:34:15 PM

ABDORIZAK ABDALLA

2 Answers

New Answer

+1

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()] }

+1

Take a look at the JavaScript Date object. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date