Advertisement
aneliabogeva

Clever Lily

Jan 18th, 2021
1,055
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function squareArea(input){
  2.   let age = Number(input[0])
  3.   let priceWash = Number(input[1])
  4.   let priceToy = Number(input[2])
  5.   let counterToy = 0
  6.   let sumMoney = 0.00
  7.  
  8.   for(let i = 1; i <= age; i++){
  9.     if(i % 2 != 0){
  10.       counterToy += 1
  11.     }else{
  12.       sumMoney += (i/2)*10
  13.       sumMoney -= 1
  14.     }
  15.   }
  16.  
  17.   let totalMoney = counterToy * priceToy + sumMoney
  18.   let diff = Math.abs(totalMoney - priceWash)
  19.  
  20.   if(totalMoney >= priceWash){
  21.     console.log(`Yes! ${diff.toFixed(2)}`)
  22.   }else {
  23.     console.log(`Yes! ${diff.toFixed(2)}`)
  24.   }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement