Greetings everyone
I’m working on the “Race Day Project” from the JavaScript course and I have a problem. The code runs well, but I notice that the final message ("See registration desk), which was supposed to be shown only for runners who are exactly 18 years old, keeps being shown to runners over 18 too (although it isn’t shown to the younger than 18 runners). Could anybody help me?
Below is my code:
let raceNumber = Math.floor(Math.random() * 1000);
let early = true;
let age = 19;
if (early && age > 18) {
raceNumber += 1000;
}
if (early && age > 18) {
console.log(`Your race will start at 9:30, your race number is ${raceNumber}.`);
}
else if (!early && age > 18) {
console.log(`Your race will start at 11:00 and your race number is ${raceNumber}.`);
}
if (age < 18) {
console.log(`Your race will start at 12:30 and your race number is ${raceNumber}.`);
}
else {
console.log(`See registration desk.`);
}