Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(juniorCount, seniorCount, raceType) {
- juniorCount = Number(juniorCount);
- seniorCount = Number(seniorCount);
- raceType = String(raceType);
- const allPrices = {
- 'trail': {
- 'juniors': 5.5,
- 'seniors': 7
- },
- 'cross-country': {
- 'juniors': 8,
- 'seniors': 9.5
- },
- 'downhill': {
- 'juniors': 12.25,
- 'seniors': 13.75
- },
- 'road': {
- 'juniors': 20,
- 'seniors': 21.5
- }
- };
- let juniorsPrice, seniorsPrice, overallPrice;
- juniorsPrice = allPrices[raceType].juniors * juniorCount;
- seniorsPrice = allPrices[raceType].seniors * seniorCount;
- overallPrice = juniorsPrice + seniorsPrice;
- if(raceType === 'cross-country' && (juniorCount + seniorCount) >= 50) {
- overallPrice *= 0.75;
- }
- overallPrice *= 0.95;
- console.log(overallPrice.toFixed(2));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement