Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(input){
- let beerPrice = 1.20
- let nameOfFan = input[0]
- let wallet = Number(input[1])
- let beerCount = Number(input[2])
- let chipsCount = Number(input[3])
- let totalBeerCost = beerCount * beerPrice
- let priceChips = 0.45 * totalBeerCost
- let totalChipsCost =(Math.ceil(chipsCount * priceChips))
- let total = totalBeerCost + totalChipsCost
- if (total <=wallet){
- total = (Math.abs(total - wallet).toFixed(2))
- console.log(`${nameOfFan} bought a snack and has ${(total)} leva left.`);
- }else {
- total =(Math.abs(total - wallet).toFixed(2))
- console.log(`${nameOfFan} needs ${total} more leva!`)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement