SHARE
TWEET

Untitled

a guest Jan 24th, 2020 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(input) {
  2.     let km = Number(input.shift());
  3.     let time = input.shift();
  4.  
  5.     let taxiPrice = 0.70 + 0.79 * km;
  6.     let taxiPriceNigt = 0.70 + 0.90 * km;
  7.     let busPrice = 0.09 * km;
  8.     let trainPrice = 0.06 * km;
  9.  
  10.     if (time === "night"){
  11.         if (km < 20) {
  12.             console.log(taxiPrice.toFixed(2));
  13.         }else if (km < 100){
  14.             console.log(busPrice.toFixed(2));
  15.         }else{
  16.             console.log(trainPrice.toFixed(2));
  17.         }
  18.  
  19.     }else{
  20.         if(km < 20 ){
  21.             console.log(taxiPriceNigt.toFixed(2));
  22.         }else if(km < 100){
  23.             console.log(busPrice.toFixed(2));
  24.         }else{
  25.             console.log(trainPrice.toFixed(2));
  26.         }
  27.     }
  28. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top