Advertisement
DraconiusNX

Untitled

Sep 19th, 2022
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function transportCosts(data) {
  2.     var totalDistance = Number(data[0]);
  3.     var dayTime = data[1];
  4.  
  5.     var sumTaxiDay = 0.7 + totalDistance * 0.79;
  6.     var sumTaxiNight = 0.7 + totalDistance * 0.90;
  7.     var sumBus = totalDistance * 0.09;
  8.     var sumTrain = totalDistance * 0.06;
  9.  
  10.     if (totalDistance < 20 && dayTime == "day") {
  11.         console.log(sumTaxiDay.toFixed(2));
  12.     }
  13.     else if (totalDistance < 20 && dayTime == "night") {
  14.         console.log(sumTaxiNight.toFixed(2));
  15.     }
  16.     else if (totalDistance >= 20 && totalDistance <= 100) {
  17.         console.log(sumBus.toFixed(2));
  18.     }
  19.     else {
  20.         console.log(sumTrain.toFixed(2));
  21.     }
  22. }
  23.  
  24. transportCosts(['180', 'night']);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement