Well, first you get the date at the current time (today), then you subtract a day from it:
const today = new Date() const yesterday = new Date(today) yesterday.setDate(yesterday.getDate() - 1) today.toDateString() yesterday.toDateString()
We use the
setDate() method on
yesterday, passing as parameter the current day minus one.