Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function houseParty(arr) {
  2.  
  3.     let list = [];
  4.     let guestName = ''
  5.  
  6.     for (let i = 0; i < arr.length; i++) {
  7.         let name = arr[i];
  8.  
  9.  
  10.  
  11.         for (let j = 0; j < name.length; j++) {
  12.             let element = name.split(" ");
  13.             let guestName = element[0];
  14.  
  15.             if (name[2] !== 'not') {
  16.                 list.push(guestName);
  17.                 name = arr[i];
  18.             } else {
  19.                 console.log(`${guestName} is not in the list!`);
  20.             }
  21.  
  22.             if (list.includes(guestName) === true) {
  23.                 console.log(`${guestName} is already in the list!`);
  24.             }
  25.  
  26.            
  27.         }
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.         console.log(list.join('\n'));
  35.  
  36.     }
  37. }
  38.  
  39.  
  40.  
  41. houseParty(['Tom is going!', 'Annie is going!', 'Tom is going!', 'Garry is going!', 'Jerry is going!']);
  42. 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