Advertisement
kstoyanov

04. Party Time js fundamentals

Jul 11th, 2020
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(args) {
  2.   const vipGuestsList = [];
  3.   const regularGuestsList = [];
  4.  
  5.   const guestList = args.splice(0, args.indexOf('PARTY'));
  6.  
  7.   guestList.forEach((reservation) => {
  8.     if (/^\d+/.test(reservation)) {
  9.       vipGuestsList.push(reservation);
  10.     } else {
  11.       regularGuestsList.push(reservation);
  12.     }
  13.   });
  14.  
  15.   args.forEach((guest) => {
  16.     if (vipGuestsList.indexOf(guest) >= 0) {
  17.       vipGuestsList.splice(vipGuestsList.indexOf(guest), 1);
  18.     }
  19.     if (regularGuestsList.indexOf(guest) >= 0) {
  20.       regularGuestsList.splice(regularGuestsList.indexOf(guest), 1);
  21.     }
  22.   });
  23.  
  24.   const allMissingGuest = [...vipGuestsList, ...regularGuestsList];
  25.  
  26.   console.log(allMissingGuest.length);
  27.   vipGuestsList.forEach((el) => console.log(el));
  28.   regularGuestsList.forEach((el) => console.log(el));
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement