TZinovieva

Bike Race 100/100

May 26th, 2022
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function bikeRace(input) {
  2.     let juniors = Number(input[0]);
  3.     let seniors = Number(input[1]);
  4.     let route = input[2];
  5.  
  6.     let fee = 0;
  7.     if (route === "trail") {
  8.         fee = juniors * 5.50 + seniors * 7;
  9.     } else if (route === "cross-country") {
  10.         fee = juniors * 8 + seniors * 9.50;
  11.     } else if (route === "downhill") {
  12.         fee = juniors * 12.25 + seniors * 13.75;
  13.     } else {
  14.         fee = juniors * 20 + seniors * 21.50;
  15.     }
  16.     if (route === "cross-country" && (juniors + seniors) >= 50) {
  17.         fee = fee - fee * 0.25;
  18.     }
  19.     let costs = fee * 5 / 100;
  20.     let donation = fee - costs;
  21.     console.log(donation.toFixed(2));
  22. }
Advertisement
Add Comment
Please, Sign In to add comment