I have an object which looks as so:
const hours = {
Monday: ['9:00 am', '4:00 pm'],
Tuesday: ['9:00 am', '4:00 pm'],
Wednesday:['9:00 am', '3:00 pm']
Thursday: ['9:00 am', '3:00 pm'],
Friday: ['9:00 am', '3:00 pm'],
Saturday: "Closed",
Sunday: "Closed",
}
I then get the current day of the week in a string format:
const d = new Date();
let day = d.getDay();
const daysOfWeek = {
1: 'Monday',
2: 'Tuesday',
3: 'Wednesday',
4: 'Thursday',
5: 'Friday',
6: 'Saturday',
7: 'Sunday'
}
const currentDayString = daysOfWeek[day]
I now need to create a new object that has the current day, up until sunday.
ex output
if the day is 'Friday' the hours
obj should be:
{
Friday: ['9:00 am', '3:00 pm'],
Saturday: "Closed",
Sunday: "Closed"
}
How can I achieve this?