aneliabogeva

Clever Lily

Jan 18th, 2021
641
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. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×