// given: date, day let time = date.getTime() const daysToAdd = day - date.getDay() time += daysToAdd * 24 * 60 * 60 * 1000 return new Date(time)