Advertisement
Spocoman

02. Bike Race

Dec 22nd, 2021 (edited)
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function bikeRace(input) {
  2.     let junior = parseInt(input[0]);
  3.     let senior = parseInt(input[1]);
  4.     let trace = input[2];
  5.     let junSum = 0;
  6.     let senSum = 0;
  7.     let sum = 0;
  8.  
  9.     if (trace === 'trail') {
  10.         junSum = 5.5;
  11.         senSum = 7;
  12.     } else if (trace === 'cross-country') {
  13.         junSum = 8;
  14.         senSum = 9.5;
  15.     } else if (trace === 'downhill') {
  16.         junSum = 12.25;
  17.         senSum = 13.75;
  18.     } else if (trace === 'road') {
  19.         junSum = 20;
  20.         senSum = 21.5;
  21.     }
  22.  
  23.     sum = junior * junSum + senior * senSum;
  24.  
  25.     if (trace === 'cross-country' && junior + senior >= 50) {
  26.         sum = 0.75 * sum;
  27.     }
  28.     console.log(`${(0.95 * sum).toFixed(2)}`);
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement