DEV Community

Discussion on: Daily Challenge #27 - Unlucky Days

Collapse
 
willsmart profile image
willsmart

Javascript shorty

matchingDayCount = (year, dayOfMonth=13, dayOfWeek=5) => 
  [...Array(12)].reduce((acc, _, month) =>
    acc + Number(new Date(year, month, dayOfMonth).getDay() == dayOfWeek), 0)

[2015, 1986].map(y => matchingDayCount(y)).join() // >> 3,1