Last active
April 12, 2022 13:07
-
-
Save theer1k/e987949556a41a4687c27d7076de435c to your computer and use it in GitHub Desktop.
[Javascript] Most Frequent Days
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const mostFrequentDays = year => { | |
let dayName = d => d.toLocaleString('en',{ weekday:'long' }); | |
let firstDay = new Date(year, 0, 1); | |
let day = dayName(firstDay); | |
let lastDay = dayName(new Date(year, 11, 31)); | |
let daysResult = day == lastDay? [day] : [day, lastDay]; | |
return firstDay.getDay() ? daysResult : daysResult.reverse(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment