Advertisement
Guest User

Party Time

a guest
Jul 12th, 2020
536
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function partyTime(input) {
  2.     let invitedList = input.splice(0, input.indexOf("PARTY"));
  3.     input.splice(0, 1);
  4.     let VIP = [];
  5.     let regular = [];
  6.     for (let guest of invitedList) {
  7.         if (guest[0] >= '0' && guest[0] <= '9') {
  8.             VIP.push(guest);
  9.         } else {
  10.             regular.push(guest);
  11.         }
  12.     }
  13.     for (let guest of input) {
  14.         if (VIP.includes(guest)) {
  15.             VIP = VIP.filter(x => x !== guest);
  16.         }
  17.         if (regular.includes(guest)) {
  18.             regular = regular.filter(x => x !== guest);
  19.         }
  20.     }
  21.  
  22.     console.log(VIP.length + regular.length);
  23.     VIP.forEach(x => {
  24.         console.log(x);
  25.     });
  26.     regular.forEach(x => {
  27.         console.log(x);
  28.     });
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement