Advertisement
mark79

Safari

May 12th, 2019
690
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function safari(input) {
  2.     let budget = Number(input.shift());
  3.     let fuelQty = number(input.shift());
  4.     let dayOfWeek = input.shift();
  5.  
  6.     let fuelTotalPrice = fuelQty * 2.1;
  7.     let totalPrice = fuelTotalPrice + 100;
  8.     totalPrice *= dayOfWeek == "Saturday" ? 0.9 : 0.8;
  9.    
  10.     let result = Math.abs(totalPrice - budget);
  11.     if (totalPrice > budget) {
  12.         console.log(`Not enough money! Money needed: ${result.toFixed(2)} lv.`);
  13.     } else {
  14.         console.log(`Safari time! Money left: ${result.toFixed(2)} lv.`);
  15.     }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement