To get the day of the week from the day number in JavaScript, we call the toLocaleString
method.
For instance, we write
const weekday = new Date().toLocaleString("en-us", { weekday: "long" });
to call toLocaleString
on a date object with the locale and an object specifying the date string returned.
We set weekday
to 'long'
to return the day of the week.