Advertisement
vladovip

JS_FUND_PartyTime

Mar 10th, 2023
775
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function party(input){
  2.     let vipList = [];
  3.     let regList = [];
  4.     let reservation = input.shift();
  5.  
  6.     while(reservation !="PARTY"){
  7.         if(/^\d+/.test(reservation)){
  8.             vipList.push(reservation);
  9.         } else {
  10.             regList.push(reservation);
  11.         }
  12.  
  13.         reservation = input.shift();
  14.     }
  15.  
  16.     for (const guest of input) {
  17.         if(vipList.includes(guest)){
  18.             vipList.splice(vipList.indexOf(guest), 1);
  19.         }
  20.        
  21.         if(regList.includes(guest)){
  22.             regList.splice(regList.indexOf(guest),1);
  23.         }
  24.     }
  25.  
  26.     console.log(vipList.length + regList.length);
  27.     vipList.forEach(element => console.log(element));
  28.     regList.forEach(element => console.log(element));
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement