Liliana797979

transport price

Dec 5th, 2020
796
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. unction transportPrice([distance, dayOrNight]) {
  2.     let price = 0;
  3.     let taksiRate = 0;
  4.  
  5.     if (dayOrNight === "day") {
  6.         taksiRate = 0.79;
  7.     } else {
  8.         taksiRate = 0.90;  
  9.     }
  10.  
  11.     if (distance < 20) {
  12.         price = 0.70 + (distance * taksiRate);
  13.     } else if (distance < 100) {
  14.         price = distance * 0.09;
  15.     } else {
  16.         price = distance * 0.09;
  17.     }
  18.     console.log(price.toFixed(2));
  19. }
  20.  
  21. transportPrice("5", "day");
Advertisement
Add Comment
Please, Sign In to add comment