Advertisement
Liliana797979

viarno reshenie clever Lili

Feb 12th, 2021
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function cleverLilly(input){
  2.     let age = Number(input[0]);
  3.     let washingMachine = Number(input[1]);
  4.     let toyPrice = Number(input[2]);
  5.  
  6.     let sumOfToys = 0;
  7.     let sumOfMoney = 0;
  8.     let currentMoney = 10;
  9.  
  10.     for(let i = 1; i <= age; i++){
  11.         if(i % 2 === 0){
  12.             sumOfMoney += currentMoney;
  13.             sumOfMoney -= 1;
  14.             currentMoney += 10;
  15.  
  16.         }else{
  17.             sumOfToys++
  18.         }
  19.  
  20.     }
  21.     sumOfMoney += sumOfToys * toyPrice;
  22.     if(sumOfMoney >= washingMachine){
  23.         console.log(`Yes! ${(sumOfMoney - washingMachine).toFixed(2)}`)
  24.     }else{
  25.         let result = Math.abs(washingMachine - sumOfMoney);
  26.         console.log(`No! ${(result).toFixed(2)}`);
  27.     }
  28.  
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement