Advertisement
knoteva

Untitled

Oct 24th, 2019
1,131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function houseParty(arr) {
  2.   let list = [];
  3.   let guestName = ''
  4.  
  5.   for (let i = 0; i < arr.length; i++) {
  6.       let line = arr[i].split(" ");
  7.       let name = line[0];
  8.       let command = line[2];
  9.           if (command !== 'not') {
  10.             if (list.includes(name) === true) {
  11.               console.log(`${name} is already in the list!`);
  12.               continue;
  13.           }
  14.           list.push(name);            
  15.           } else {
  16.             if (list.includes(name) === false) {
  17.               console.log(`${name} is not in the list!`);
  18.               continue;
  19.             }
  20.               list = list.filter(x => x!= name);
  21.           }
  22.   }
  23.   console.log(list.join('\n'));
  24. }
  25.  
  26. //houseParty(['Tom is going!', 'Annie is going!', 'Tom is going!', 'Garry is going!', 'Jerry is going!']);
  27. houseParty(['Allie is going!', 'George is going!', 'John is not going!', 'George is not going!'])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement