Advertisement
Guest User

PartyTime

a guest
Jul 12th, 2020
1,290
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.splice(VIP.indexOf(guest), 1);
  16.         }
  17.         if (regular.includes(guest)) {
  18.             regular.splice(regular.indexOf(guest), 1);
  19.         }
  20.     }
  21.     console.log(VIP.length + regular.length);
  22.     VIP.forEach((x) => console.log(x));
  23.     regular.forEach((x) => console.log(x));
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement