Advertisement
Guest User

Untitled

a guest
Jan 21st, 2018
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 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"}];
  2. let fwh = [];
  3. for(let i = 0; i < wh.length; i++){
  4.     let h = wh[i].hours;
  5.     let found = false;
  6.     for(let j = 0; j < fwh.length; j++){
  7.         if(fwh[j].hours === wh[i].hours){
  8.             found = true;
  9.             fwh[j].days.push(i);
  10.         }
  11.     }
  12.     if(!found){
  13.         fwh.push({days:[i], hours:wh[i].hours});
  14.     }
  15. }
  16. console.log(fwh);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement