Race Day

Hi,All!

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

let registeredEarly = false;

const age = 20;

if (registeredEarly = true && age>= 18) { raceNumber = raceNumber + 1000 ;

};

if ( registeredEarly = true && age > 18 ) {

console.log(`Your race starts at 9:30 AM!, your race number is ${raceNumber}`);

}

else if ( registeredEarly = false && age > 18) {

console.log ('Late adults run at 11:00 am');

}

else if (age< 18) {

console.log(`Your race starts at 12:30 AM!, your race number is ${raceNumber}`)

} 

Output : Your race starts at 9:30 AM!, your race number is 1804
It must be 11:00 AM, can you please help me, where is the mistake?

Thanks!

well, there seems to be a problem with your if condition, so then the first logic step would be log the variable involved to see if that helps us narrow down the problem:

console.log(registeredEarly = true, age > 18);

which tells us both of these are true. For age > 18 this make sense.

for the early registration not so much. So then the logic place to look is the comparison operator. Could there a problem there?

1 Like

Thank you! Works :laughing: :sob: :exploding_head:

1 Like

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.