I have the following code to generate the current date in a specific format. I want to have an if statement that will change the back ground color and the font color depending if the specific day is on a Sunday, Saturday, or a Week day.
var date = new Date();
var dayMonthYear = date.toLocaleString('en-US', {month:'long',day:'numeric',year:'numeric'}).replaceAll(", ", "-");
var weekday = date.toLocaleString('en-US', { weekday: 'long' })
document.write(dayMonthYear + ' [' + weekday + ']');
I thought I would just create a general if statement that looks at the weekday variable but it doesn't seem to work correctly like I would think.
if (weekday = 'Sunday') {
background-color:aqua;
color: blue;
}
Also, any ideas on how to get a - between the Month and Day number?
Example: August-15-2021
My current code generates August 15-2021