If I have an object with store information that looks like this.
storeHours:
0:
day: Sunday
Open: 9:00am
close: 6:00pm
0:
day: Monday
Open: 8:00am
close: 10:00pm
0:
day: Tuesday
Open: 8:00am
close: 10:00pm
0:
day: Wednesday
Open: 8:00am
close: 10:00pm
0:
day: Thursday
Open: 8:00am
close: 10:00pm
0:
day: Friday
Open: 8:00am
close: 10:00pm
0:
day: Saturday
Open: 9:00am
close: 6:00pm
What function should I write to get output that would give me
simplestoreHours:
0:
Days: Monday-Friday
open: 8:00am
close: 6:00pm
1:
Days: Saturday-Sunday
open: 9:00am
close: 6:00pm
Also all the times are formatted momentjs objects so it is possible to use momentjs.
My initial thought is to do a loop and have each element checked against each other. If the open and closing times are the same then just connect the days, but I don't think this very clever.