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