You could perhaps do something like this?
const newHolidays = holidays.map(holiday => {
return addBusinessDays(new Date(holiday), 3);
});
console.log(newHolidays);
newHolidays - This is a new array (leaving the original intact) containing each of the dates + 3 days
Read about .map here
.map calls a provided callback function once for each element in an array, in order, and constructs a new array from the results.
You may want to also 'parse' the dates using date-fns as mentioned in the comments. You could do this like so:
function parseDates(dates) {
return dates.map(date => {
return parse(date, "yyyy-MM-dd", new Date());
});
}
const parsedHolidays = parseDates(holidays);
Then you would want to change 'newHolidays' to similar to this:
const newHolidays = parsedHolidays.map(holiday => {
return addBusinessDays(new Date(holiday), 3);
});
Or, you could move the parse function into the holidays.map if you'd prefer to parsed them one by one just before using addBusinessDays