DEV Community

loading...

Discussion on: Daily Challenge #303 - Frequent Days in a Year

Collapse
soorajsnblaze333 profile image
Sooraj

Tried a different approach

const mostFrequentDays = (year) => {
  const dayValues = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]; 
  let days = [];
  days.push(dayValues[new Date('01-01-'+year).getDay()])
  if (year % 4 === 0) days.push(dayValues[new Date('01-02-'+year).getDay()]);
  return days;
}
Enter fullscreen mode Exit fullscreen mode