neZnam121

Untitled

Feb 27th, 2022
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function christmasGifts(input){
  2.    const toyPrice=5;
  3.    const sweatersPrice=15;
  4.    let adultCounter=0;
  5.    let kidsCounter=0;
  6.    let toyCounter=0;
  7.    let sweatersCounter=0;
  8.    let moneyForToys=0;
  9.    let moneyForsweaters=0;
  10.    
  11.  
  12.    
  13.    for (let i = 0; i < input.length; i++) {
  14.        if(Number(input[i]) <= 16 ){
  15.             kidsCounter += 1;
  16.             toyCounter += 1;
  17.             moneyForToys= toyCounter * toyPrice;
  18.            
  19.        }else if (Number(input[i]) > 16) {
  20.             adultCounter += 1;
  21.             sweatersCounter += 1;
  22.             moneyForsweaters=sweatersCounter*sweatersPrice;
  23.        }else if (input[i] == "Christmas" ) {
  24.            console.log(`Number of adults: ${adultCounter}`);
  25.            console.log(`Number of kids: ${kidsCounter}`);
  26.            console.log(`Money for toys: ${moneyForToys}`);
  27.            console.log(`Money for sweaters: ${moneyForsweaters}`);
  28.            break
  29.        }
  30.        
  31.    }
  32.  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment