Advertisement
Guest User

Untitled

a guest
Nov 14th, 2020
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function partyTime(guests) {
  2.     let guestListArr = guests.splice(0, guests.indexOf('PARTY'));
  3.     let guestList = new Map();
  4.     guestList.set('VIP', []);
  5.     guestList.set('regular', []);
  6.     guests.splice(1, guests.length - 1).forEach(x => {
  7.         if (guestListArr.includes(x)) { guestListArr.splice(guestListArr.indexOf(x), 1) }
  8.     });
  9.  
  10.     guestList.set('VIP', guestList.get('VIP').concat(guestListArr.filter(x => !isNaN(x[0]))));
  11.     guestList.set('regular', guestList.get('regular').concat(guestListArr.filter(x => isNaN(x[0]))));
  12.     console.log(guestList.get('VIP').length + guestList.get('regular').length);
  13.     [...guestList].map(x => console.log(x[1].join('\n')));
  14. }
  15.  
  16. partyTime(['7IK9Yo0h',
  17. '9NoBUajQ',
  18. 'Ce8vwPmE',
  19. 'SVQXQCbc',
  20. 'tSzE5t0p',
  21. 'PARTY',
  22. '9NoBUajQ',
  23. 'Ce8vwPmE',
  24. 'SVQXQCbc'
  25. ]
  26. );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement