function getNextFridayDate(date = new Date()) {
const today = new Date(date.getTime());
const nextFriday = new Date(
today.setDate(today.getDate() + ((7 - today.getDay() + 5) % 7 || 7),
),
);
return nextFriday;
}
console.log(getNextFridayDate(new Date()).toDateString());
/*
run:
"Fri Apr 08 2022"
*/