Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function transportCosts(data) {
- var totalDistance = Number(data[0]);
- var dayTime = data[1];
- var sumTaxiDay = 0.7 + totalDistance * 0.79;
- var sumTaxiNight = 0.7 + totalDistance * 0.90;
- var sumBus = totalDistance * 0.09;
- var sumTrain = totalDistance * 0.06;
- if (totalDistance < 20 && dayTime == "day") {
- console.log(sumTaxiDay.toFixed(2));
- }
- else if (totalDistance < 20 && dayTime == "night") {
- console.log(sumTaxiNight.toFixed(2));
- }
- else if (totalDistance >= 20 && totalDistance <= 100) {
- console.log(sumBus.toFixed(2));
- }
- else {
- console.log(sumTrain.toFixed(2));
- }
- }
- transportCosts(['180', 'night']);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement