Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function bikeRace(input) {
- let juniors = Number(input[0]);
- let seniors = Number(input[1]);
- let route = input[2];
- let fee = 0;
- if (route === "trail") {
- fee = juniors * 5.50 + seniors * 7;
- } else if (route === "cross-country") {
- fee = juniors * 8 + seniors * 9.50;
- } else if (route === "downhill") {
- fee = juniors * 12.25 + seniors * 13.75;
- } else {
- fee = juniors * 20 + seniors * 21.50;
- }
- if (route === "cross-country" && (juniors + seniors) >= 50) {
- fee = fee - fee * 0.25;
- }
- let costs = fee * 5 / 100;
- let donation = fee - costs;
- console.log(donation.toFixed(2));
- }
Advertisement
Add Comment
Please, Sign In to add comment