Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let wh = [{"hours":"no"},{"hours": "09:00-17:00"},{"hours": "09:00-17:00"},{"hours": "09:00-17:00"},{"hours": "09:00-17:00"},{"hours": "09:00-17:00"},{"hours":"no"}];
- let fwh = [];
- for(let i = 0; i < wh.length; i++){
- let h = wh[i].hours;
- let found = false;
- for(let j = 0; j < fwh.length; j++){
- if(fwh[j].hours === wh[i].hours){
- found = true;
- fwh[j].days.push(i);
- }
- }
- if(!found){
- fwh.push({days:[i], hours:wh[i].hours});
- }
- }
- console.log(fwh);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement