Skip to content

Commit d4d1303

Browse files
authored
Merge pull request vJechsmayr#145 from daviccardoso/day-of-the-week-solution
Add JS file with dayOfTheWeek solution proposal
2 parents d4bf02f + ed564e8 commit d4d1303

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const dayOfTheWeek = (day, month, year) => {
2+
if (year < 1971 || year > 2100) {
3+
return 'Invalid year';
4+
}
5+
6+
const inputDate = new Date(year, month - 1, day);
7+
const dateFormatter = new Intl.DateTimeFormat('en-US', {
8+
weekday: 'long'
9+
});
10+
11+
return dateFormatter.format(inputDate);
12+
}

0 commit comments

Comments
 (0)