1const date = new Date();
2const oneWeekLater = addDaysToDate(date, 7); // also works with negative #s
3
4function addDaysToDate(date: Date, days: number): Date {
5 return new Date(date.getTime() + daysToMilliseconds(days));
6}
7
8function daysToMilliseconds(days: number): number {
9 // 24 hours, 60 minutes, 60 seconds, 1000 milliseconds
10 return days * 24 * 60 * 60 * 1000;
11}
12