Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. function transport([arg1, arg2]) {
  2. km = Number(arg1);
  3. if (arg2 == "day") {
  4. dayPrice = 0.79;
  5. nightPrice = 0;
  6. } else {
  7. nightPrice = 0.90;
  8. dayPrice = 0;
  9. }
  10. priceTaxi = (0.70 + km * dayPrice + km * nightPrice);
  11. priceBus = 0.09 * km;
  12. priceTrain = 0.06 * km;
  13. if ((priceTaxi <= priceBus && priceTaxi <= priceTrain) || km < 20) {
  14. console.log(priceTaxi);
  15. } else if ((priceBus <= priceTaxi && priceBus <= priceTrain) || km < 100) {
  16. console.log(priceBus);
  17. } else if (priceTrain <= priceTaxi && priceTrain <= priceBus && km >= 100) {
  18. console.log(priceTrain);
  19. }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement