Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function transportPrice(input) {
- let km = Number(input[0])
- let trip = input[1]
- let taxiInitialTax = 0.70
- let taxiDayTariff = 0.79;
- let taxiNightTariff = 0.90;
- let bus = 0.09;
- let train = 0.06;
- let price = 0;
- if (trip == "day" && km < 20) {
- price = (km * taxiDayTariff) + taxiInitialTax
- }
- else if (km < 20) {
- price = (km * taxiNightTariff) + taxiInitialTax;
- }
- else if (km >= 100) {
- price = (km * train);
- }
- else if (km >= 20) {
- price = km * bus;
- }
- console.log(price.toFixed(2));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement