Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function bikeRace(input) {
- let junior = parseInt(input[0]);
- let senior = parseInt(input[1]);
- let trace = input[2];
- let junSum = 0;
- let senSum = 0;
- let sum = 0;
- if (trace === 'trail') {
- junSum = 5.5;
- senSum = 7;
- } else if (trace === 'cross-country') {
- junSum = 8;
- senSum = 9.5;
- } else if (trace === 'downhill') {
- junSum = 12.25;
- senSum = 13.75;
- } else if (trace === 'road') {
- junSum = 20;
- senSum = 21.5;
- }
- sum = junior * junSum + senior * senSum;
- if (trace === 'cross-country' && junior + senior >= 50) {
- sum = 0.75 * sum;
- }
- console.log(`${(0.95 * sum).toFixed(2)}`);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement