Advertisement
Spocoman

Summer Shopping

Oct 7th, 2023
685
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function cruiseChip(input) {
  2.     let budget = Number(input[0]);
  3.     let towel = Number(input[1]);
  4.     let discount = Number(input[2]);
  5.  
  6.     let umbrella = towel / 3 * 2;
  7.     let flipFlops = umbrella * 0.75;
  8.     let beachBag = (towel + flipFlops) / 3;
  9.  
  10.     let sum = (towel + umbrella + flipFlops + beachBag) * (100 - discount) / 100;
  11.  
  12.     if (budget >= sum) {
  13.         console.log(`Annie's sum is ${sum.toFixed(2)} lv. She has ${(budget - sum).toFixed(2)} lv. left.`);
  14.    } else {
  15.        console.log(`Annie's sum is ${sum.toFixed(2)} lv. She needs ${(sum - budget).toFixed(2)} lv. more.`);
  16.     }
  17.     return;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement