Advertisement
Liliana797979

easter guests

Dec 20th, 2020
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function easterGuests(arg1, arg2) {
  2.     let guestsCount = Number(arg1);
  3.     let budget = Number(arg2);
  4.     let totalPrice = 0;
  5.  
  6.     let easterBreadCount = guestsCount / 3;
  7.     let eggsCount = guestsCount * 2;
  8.     let easterBreadPrice = easterBreadCount * 4;
  9.     let eggsPrice = eggsCount * 0.45;
  10.     totalPrice = easterBreadPrice + eggsPrice;
  11.  
  12.  
  13.     if (budget >= totalPrice) {
  14.         console.log (`Lyubo bought ${easterBreadCount} Easter bread and ${eggsCount} eggs.`);
  15.         console.log(`He has ${(budget - totalPrice).toFixed(2)} lv. left.`);
  16.  
  17.     } else if (budget < totalPrice) {
  18.     console.log(`Lyubo doesn't have enough money.`);
  19.    console.log(`He needs ${(totalPrice - budget).toFixed(2)} lv. more.`);
  20. }
  21. }
  22.  
  23. easterGuests("9", "12");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement