Race day skill path project

let raceNumber = Math.floor(Math.random() * 1000;

let runnerRegisteredEarly = true;

let runnersAge = Math.floor(Math.random() * 100);

if (runnersAge > 18 && runnerRegisteredEarly) {
  raceNumber += 1000;
}

if(runnersAge > 18 && runnerRegisteredEarly) {
  console.log(`Number ${raceNumber} will race at 9:30 am`);
} else if (runnersAge >= 18 && !runnerRegisteredEarly) {
  console.log(`Number ${raceNumber} will race at 11:00`);
} else if (runnersAge < 18) {
  console.log(`Number ${raceNumber} will race at 12:30 pm`);
} else {
  console.log(`Please, see the registration desk.`);
}

Is it okay to assign value to the runners age variable similar to the race number? I’m asking just because it is much better than to change the runners age manually.

let runnersAge = Math.floor(Math.random() * 100);

THANK YOU!

1 Like

Hallo!
It is okay and is way more fun to do that indeed :smile: :laughing: especially if a year-old racer joins the race :rofl:
Kidding aside, your solution is perfect and it will be more perfect if you specify the range for the racer’s age so that no children under a certain age are allowed.