Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(args) {
- const vipGuestsList = [];
- const regularGuestsList = [];
- const guestList = args.splice(0, args.indexOf('PARTY'));
- guestList.forEach((reservation) => {
- if (/^\d+/.test(reservation)) {
- vipGuestsList.push(reservation);
- } else {
- regularGuestsList.push(reservation);
- }
- });
- args.forEach((guest) => {
- if (vipGuestsList.indexOf(guest) >= 0) {
- vipGuestsList.splice(vipGuestsList.indexOf(guest), 1);
- }
- if (regularGuestsList.indexOf(guest) >= 0) {
- regularGuestsList.splice(regularGuestsList.indexOf(guest), 1);
- }
- });
- const allMissingGuest = [...vipGuestsList, ...regularGuestsList];
- console.log(allMissingGuest.length);
- vipGuestsList.forEach((el) => console.log(el));
- regularGuestsList.forEach((el) => console.log(el));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement