StefanShivarov

05. Christmas Gifts

Jul 25th, 2021
914
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function zad2(input){
  2.  
  3.     let adults = 0, kids = 0, toysPrice = 0, sweatersPrice = 0;
  4.  
  5.     for(let i = 0; i < input.length; i++){
  6.  
  7.         if(input[i] == 'Christmas'){
  8.             break;
  9.         }
  10.  
  11.         if(!isNaN(input[i])){
  12.             if(input[i] <= 16){
  13.  
  14.                 kids++;
  15.             }else{
  16.                
  17.                 adults++;
  18.             }
  19.         }
  20.     }
  21.  
  22.     toysPrice = kids*5;
  23.     sweatersPrice = adults*15;
  24.  
  25.     console.log(`Number of adults: ${adults}`);
  26.     console.log(`Number of kids: ${kids}`);
  27.     console.log(`Money for toys: ${toysPrice}`);
  28.     console.log(`Money for sweaters: ${sweatersPrice}`);
  29.  
  30. }
RAW Paste Data