I'm calculating the day of the week from the API and I need to replace the last element, which will be today's day to string "Today" in an array.
For example:
I have an array todayCal=[tue, wed, thu, fri, sat, sun, mon] where mon is current date's day and I've to replace that mon with 'Today' while displaying.
my code:
var weekdays = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
var d = new Date();
var day = d.getDay();
var dayCal = weekdays[day];
if(dayCal){
console.log(dayCal[6],'weekday[6]');
dayCal[6] = 'Today';
}
else {
dayCal= weekdays[day];
}
Here the last element sat is replaced with 'Today' where as I need current day to replace with 'Today'
dayCalis the day string (3 letters), sodayCal[6]isn't going to workweekdays = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];to something like['Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun', 'Mon']along the way? and then to['Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun', 'Today']?