TZinovieva

Safari JS

Dec 5th, 2022
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function safari(input) {
  2.     let budget = Number(input[0]);
  3.     let fuelQty = Number(input[1]);
  4.     let day = input[2];
  5.    
  6.     let fuelPrice = fuelQty * 2.10;
  7.     let totalPrice = fuelPrice + 100;
  8.  
  9.         if (day === "Saturday") {
  10.             totalPrice -= totalPrice * 0.10;
  11.         } else if (day === "Sunday") {
  12.             totalPrice -= totalPrice * 0.20;
  13.         }
  14.  
  15.     if (budget > totalPrice) {
  16.         console.log(`Safari time! Money left: ${(budget - totalPrice).toFixed(2)} lv.`);
  17.     } else {
  18.         console.log(`Not enough money! Money needed: ${(totalPrice - budget).toFixed(2)} lv.`);
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment