Advertisement
Grossos

christmas

Jul 2nd, 2023 (edited)
771
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function christmasGift(input) {
  2.  
  3.     let index = 0;
  4.     let command = input[index];
  5.  
  6.     let kids = 0;
  7.     let adults = 0;
  8.  
  9.     let gift = 0;
  10.     let pulover = 0;
  11.    
  12.  
  13.     while (command !== 'Christmas') {
  14.  
  15.         currentYearsOld = Number(command);
  16.  
  17.         if (currentYearsOld <= 16) {
  18.             kids++;
  19.            
  20.         } else if (currentYearsOld > 16) {
  21.             adults++;
  22.      
  23.         }
  24.  
  25.         index++;
  26.         command = input[index];
  27.  
  28.     }
  29.  
  30.     console.log(`Number of adults: ${adults}`);
  31.     console.log(`Number of kids: ${kids}`);
  32.     console.log(`Money for toys: ${kids * 5}`);
  33.     console.log(`Money for sweaters: ${adults * 15}`);
  34.  
  35. }
  36.  
  37. christmasGift(['16','20','46','12','8','20','49','Christmas'])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement