Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function easterGuests(arg1, arg2) {
- let guestsCount = Number(arg1);
- let budget = Number(arg2);
- let totalPrice = 0;
- let easterBreadCount = guestsCount / 3;
- let eggsCount = guestsCount * 2;
- let easterBreadPrice = easterBreadCount * 4;
- let eggsPrice = eggsCount * 0.45;
- totalPrice = easterBreadPrice + eggsPrice;
- if (budget >= totalPrice) {
- console.log (`Lyubo bought ${easterBreadCount} Easter bread and ${eggsCount} eggs.`);
- console.log(`He has ${(budget - totalPrice).toFixed(2)} lv. left.`);
- } else if (budget < totalPrice) {
- console.log(`Lyubo doesn't have enough money.`);
- console.log(`He needs ${(totalPrice - budget).toFixed(2)} lv. more.`);
- }
- }
- easterGuests("9", "12");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement