Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function beerAndChips(input) {
- let name = input[0];
- let budget = Number(input[1]);
- let beers = Number(input[2]) * 1.2;
- let chips = Number(input[3]) * beers * 0.45;
- let sum = beers + Math.ceil(chips);
- if(budget < sum){
- console.log(`${name} needs ${(sum - budget).toFixed(2)} more leva!`);
- } else{
- console.log(`${name} bought a snack and has ${(budget - sum).toFixed(2)} leva left.`);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement