Advertisement
Spocoman

Beer and chips

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