Liliana797979

Christmas gifts

Nov 17th, 2020
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. function solve() {
  3.     let i = 0;
  4.     let kidCounter = 0;
  5.     let adultCounter = 0;
  6.     let toysPrice = 0;
  7.     let puloverPrice = 0;
  8.  
  9.     while(input[i] == "Christmas") {
  10.         let num = Number(input[i]);
  11.  
  12.         if (num <= 16) {
  13.  
  14.         } else {
  15.             adultCounter++;
  16.         }
  17.         i++;
  18.     }
  19.     toysPrice = kidCounter * 5;
  20.     puloverPrice = adultCounter * 15;
  21.  
  22.     console.log(`Number of adults: ${adultCounter}`);
  23.     console.log(`Number of kids: ${kidCounter}`);
  24.     console.log(`Money for toys: ${toysPrice}`);
  25.     console.log(`Money for sweaters: ${puloverPrice}`);
  26. }
Advertisement
Add Comment
Please, Sign In to add comment