kvnallen
6/28/2017 - 7:24 PM

useful-day.js

const NOT = x => !x
const isWeekend = day => day % 6 === 0
const isHoliday = monthHolidays => day => monthHolidays.includes(day)
const isUsefulDay = (monthHolidays) => (day) => NOT( isWeekend ( day ) ) && NOT( isHoliday (monthHolidays)( day ) ) 

/////////////////////////////

const holidays = [1,2,3,4,5]
const range = Array(10).fill().map((_, i) => (i * 1) + 1).reverse()
const usefulDay = range.find(i => isUsefulDay(holidays)(i))

console.log('should be 10', usefulDay)