You can also use the Date constructor, which automatically handles date wrapping when adding or subtracting days.
const today = new Date();
const fiveDaysAgo = new Date(today.setDate(today.getDate() - 5)); // Subtract 5 days
console.log(fiveDaysAgo);
This approach returns a new Date object, so you won’t modify the original today variable.