Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve (arr) {
- let indexOfParty = arr.indexOf('PARTY');
- let guestList = arr.splice(0, indexOfParty);
- arr.shift();
- // console.log(arr);
- let vip = [];
- let regular = [];
- for (let el of guestList) {
- if (isNaN(el[0])) {
- regular.push(el);
- } else {
- vip.push(el);
- }
- }
- for (let el of arr) {
- if (regular.includes(el)) {
- let index = regular.indexOf(el);
- regular.splice(index, 1);
- } else if (vip.includes(el)) {
- let index = vip.indexOf(el);
- vip.splice(index, 1);
- }
- }
- let countAbsentGuests = regular.length + vip.length;
- console.log(countAbsentGuests);
- for (let el of vip) {
- console.log(el);
- }
- for (let el of regular) {
- console.log(el);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement