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