Advertisement
Guest User

Untitled

a guest
Feb 21st, 2020
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. function houseParty(whoIsComing) {
  2. let comingGuests = [];
  3.  
  4. for (let currentString of whoIsComing) {
  5. let currentGuest = currentString.split(' ')[0];
  6. if (!(currentString.includes('not'))) {
  7. if (comingGuests.includes(currentGuest)) {
  8. console.log(`${currentGuest} is already in the list!`);
  9. } else {
  10. comingGuests.push(currentGuest)
  11. }
  12. }else{
  13. if (comingGuests.includes(currentGuest)) {
  14. comingGuests.pop(currentGuest)
  15. } else {
  16. console.log(`${currentGuest} is not in the list!`);
  17. }
  18. }
  19. }
  20. for(let name of comingGuests){
  21. console.log(name);
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement