ErolKZ

Untitled

Nov 8th, 2021
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1.  
  2. function solve (arr) {
  3.  
  4.  
  5. let indexOfParty = arr.indexOf('PARTY');
  6.  
  7. let guestList = arr.slice(0, indexOfParty);
  8.  
  9. let guestsAtParty = arr.slice(indexOfParty + 1);
  10.  
  11.  
  12. let absentGuests = guestList.filter(el => !guestsAtParty.includes(el) ? el : false);
  13.  
  14.  
  15. console.log(absentGuests.length);
  16.  
  17. // console.log(absentGuests);
  18.  
  19.  
  20.  
  21. for (let el of absentGuests) {
  22.  
  23. if (Number(el[0])) {
  24.  
  25. console.log(el);
  26.  
  27. absentGuests.splice(absentGuests.indexOf(el), 1);
  28.  
  29. }
  30.  
  31. }
  32.  
  33.  
  34. for (let el of absentGuests) {
  35.  
  36. console.log(el);
  37.  
  38. }
  39.  
  40.  
  41.  
  42. }
  43.  
Advertisement
Add Comment
Please, Sign In to add comment