Advertisement
ErolKZ

Untitled

Nov 8th, 2021
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1.  
  2. function solve (arr) {
  3.  
  4.  
  5. let indexOfParty = arr.indexOf('PARTY');
  6.  
  7. let guestList = arr.splice(0, indexOfParty);
  8.  
  9. arr.shift();
  10.  
  11. // console.log(arr);
  12.  
  13. let vip = [];
  14.  
  15. let regular = [];
  16.  
  17.  
  18. for (let el of guestList) {
  19.  
  20. if (isNaN(el[0])) {
  21.  
  22. regular.push(el);
  23.  
  24. } else {
  25.  
  26. vip.push(el);
  27.  
  28. }
  29.  
  30. }
  31.  
  32.  
  33.  
  34. for (let el of arr) {
  35.  
  36. if (regular.includes(el)) {
  37.  
  38. let index = regular.indexOf(el);
  39.  
  40. regular.splice(index, 1);
  41.  
  42. } else if (vip.includes(el)) {
  43.  
  44. let index = vip.indexOf(el);
  45.  
  46. vip.splice(index, 1);
  47.  
  48. }
  49.  
  50. }
  51.  
  52.  
  53. let countAbsentGuests = regular.length + vip.length;
  54.  
  55. console.log(countAbsentGuests);
  56.  
  57.  
  58. for (let el of vip) {
  59.  
  60. console.log(el);
  61.  
  62. }
  63.  
  64.  
  65. for (let el of regular) {
  66.  
  67. console.log(el);
  68.  
  69. }
  70.  
  71.  
  72. }
  73.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement