Advertisement
Czopski

Guest list

Feb 8th, 2023 (edited)
805
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //funkcja pozwalająca na wpisanie listy gości i sprawdzenie czy dany gość jest na liście.
  2.  
  3. var guestList = [];
  4.  
  5.  
  6. function enterTheGuestList() {
  7.    
  8.     var numberOfGuests = prompt("Podaj liczbę swoich gości: ");
  9.    
  10.     for (var index = 0; index < numberOfGuests; index++) {
  11.         guestList.push(prompt("Podaj imię gościa"));
  12.     }
  13.  
  14.     return guestList;
  15. }
  16.  
  17. function showGuestList() {
  18.     alert(guestList);
  19. };
  20.  
  21. function checkIfItsOnTheList() {
  22.     var answer = "brak";
  23.     while (answer) {
  24.         answer = prompt("Podaj imię gościa");
  25.         if (guestList.includes(answer)){
  26.             alert("Hello there")
  27.         }
  28.         else{
  29.             alert("Go away!")
  30.         }
  31.     }
  32. };
  33.  
  34. enterTheGuestList();
  35. showGuestList();
  36. checkIfItsOnTheList();
  37.  
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement