Advertisement
DraconiusNX

Untitled

Sep 21st, 2022
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function transportPrice(input) {
  2.     let distance = Number(input[0]);
  3.     let timeOfDay = input[1];
  4.     let dayTaxi = distance * 0.79 + 0.70;
  5.     let nightTaxi = distance * 0.90 + 0.70;
  6.     let bus = distance * 0.09;
  7.     let train = distance * 0.06;
  8.  
  9.     let cheaper = bus > train;
  10.  
  11. if (distance < 20 && timeOfDay === "day") {
  12.     console.log(dayTaxi.toFixed(2));
  13. } else if (distance < 20 && timeOfDay === "night") {
  14.     console.log(nightTaxi.toFixed(2));
  15. } else if (cheaper === true) {
  16.     if (distance >= 100) {
  17.         console.log(train.toFixed(2));
  18.     } else {
  19.         console.log(bus.toFixed(2));
  20.     }
  21. } else {
  22.     console.log(bus.toFixed(2));
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement