Advertisement
Spocoman

Sweet Dessert

Oct 1st, 2023
948
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function sweetDessert(input) {
  2.     let budget = Number(input[0]);
  3.     let guests = Number(input[1]);
  4.     let bananaPrice = Number(input[2]);
  5.     let eggPrice = Number(input[3]);
  6.     let berriesKiloPrice = Number(input[4]);
  7.  
  8.     let neededMoney = Math.ceil(guests / 6) * (bananaPrice * 2 + eggPrice * 4 + berriesKiloPrice / 5);
  9.  
  10.     if (budget >= neededMoney) {
  11.         console.log(`Ivancho has enough money - it would cost ${neededMoney.toFixed(2)}lv.`);
  12.     }
  13.     else {
  14.         console.log(`Ivancho will have to withdraw money - he will need ${(neededMoney - budget).toFixed(2)}lv more.`);
  15.     }
  16.  
  17.     return;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement