Advertisement
Spocoman

Easter Guests

Feb 21st, 2022
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function easterGuests(input) {
  2.     let guest = Number(input.shift());
  3.     let budget = Number(input.shift());
  4.  
  5.     let sum = Math.ceil(guest / 3) * 4 + guest * 2 * 0.45;
  6.  
  7.     if (budget >= sum) {
  8.         console.log(`Lyubo bought ${Math.ceil(guest / 3)} Easter bread and ${guest * 2} eggs.`);
  9.         console.log(`He has ${(budget - sum).toFixed(2)} lv. left.`);
  10.     } else {
  11.         console.log("Lyubo doesn't have enough money.");
  12.         console.log(`He needs ${(sum - budget).toFixed(2)} lv. more.`);
  13.     }
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement