Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function houseParty(whoIsComing) {
- let comingGuests = [];
- for (let currentString of whoIsComing) {
- let currentGuest = currentString.split(' ')[0];
- if (!(currentString.includes('not'))) {
- if (comingGuests.includes(currentGuest)) {
- console.log(`${currentGuest} is already in the list!`);
- } else {
- comingGuests.push(currentGuest)
- }
- }else{
- if (comingGuests.includes(currentGuest)) {
- comingGuests.pop(currentGuest)
- } else {
- console.log(`${currentGuest} is not in the list!`);
- }
- }
- }
- for(let name of comingGuests){
- console.log(name);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement