function getDateOfNDaysAgo(days, date = new Date()) {
const dateAgo = new Date(date.getTime());
dateAgo.setDate(date.getDate() - days);
return dateAgo;
}
console.log(getDateOfNDaysAgo(11, new Date('2022-03-12')).toDateString());
/*
run:
Tue Mar 01 2022
*/