Advertisement
Guest User

Untitled

a guest
Dec 14th, 2021
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function transportPrice(input) {
  2.     let km = Number(input[0])
  3.     let trip = input[1]
  4.  
  5.     let taxiInitialTax = 0.70
  6.     let taxiDayTariff = 0.79;
  7.     let taxiNightTariff = 0.90;
  8.     let bus = 0.09;
  9.     let train = 0.06;
  10.     let price = 0;
  11.  
  12.     if (trip == "day" && km < 20) {
  13.         price = (km * taxiDayTariff) + taxiInitialTax
  14.     }
  15.     else if (km < 20) {
  16.         price = (km * taxiNightTariff) + taxiInitialTax;
  17.     }
  18.     else if (km >= 100) {
  19.         price = (km * train);
  20.     }
  21.     else if (km >= 20) {
  22.         price = km * bus;
  23.     }
  24.  
  25.     console.log(price.toFixed(2));
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement