countWeekDaysBetween
Counts the weekdays between two dates.
- Use
Array.from()
to construct an array withlength
equal to the number of days betweenstartDate
andendDate
. - Use
Array.prototype.reduce()
to iterate over the array, checking if each date is a weekday and incrementingcount
. - Update
startDate
with the next day each loop usingDate.prototype.getDate()
andDate.prototype.setDate()
to advance it by one day. - NOTE: Does not take official holidays into account.