Advertisement
Spocoman

Easter Party

Feb 21st, 2022
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function easterParty(input) {
  2.     let guest = Number(input.shift());
  3.     let envelope = Number(input.shift());
  4.     let budget = Number(input.shift());
  5.  
  6.     let sum = guest * envelope;
  7.  
  8.     if (guest >= 10 && guest <= 15) {
  9.         sum *= 0.85;
  10.     } else if (guest > 15 && guest <= 20) {
  11.         sum *= 0.8;
  12.     } else if (guest > 20) {
  13.         sum *= 0.75;
  14.     }
  15.     sum += budget / 10;
  16.  
  17.     if (budget >= sum) {
  18.         console.log(`It is party time! ${(budget - sum).toFixed(2)} leva left.`);
  19.     } else {
  20.         console.log(`No party! ${(sum - budget).toFixed(2)} leva needed.`);
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement