I would like for the previous Monday to appear in the field where a user enters today\'s date.
E.g.: If today\'s date is entered 29-Jan-16
t
Thank you @Philippe Dubé-Tremblay for your nice solution (above),
I will just put here the wrapping function for those who, like me, plan to call this function repeatedly.
// Accepts a date as parameter or with no parameter will assume the current date.
const getPreviousMonday = (date = null) => {
const prevMonday = date && new Date(date.valueOf()) || new Date()
prevMonday.setDate(prevMonday.getDate() - (prevMonday.getDay() + 6) % 7)
return prevMonday
}