What did I do wrong? JavaScript - Race Day Exercise

No matter what I change the earlyReg to, it always registers as true.
When I was trying to debug for typos on that, I have since lost the ability for the code to function past the first if statement. Sure it’s something dumb, but I can’t find it.

let raceNumber = Math.floor(Math.random() * 1000);
var earlyReg = true;
var age = 38;
if (earlyReg = true && age > 18){
raceNumber += 1000
};
if (earlyReg && age > 18){
console.log('Racer number ’ + ${raceNumber} + ‘, you will race at 9:30 am.’)
} else if (!earlyReg && age > 18){
console.log(‘Racer number ’ + ${raceNumber} + ‘, you will race at 11:00 am.’’)
} else if (age < 18){
console.log('Racer number ’ + ${raceNumber} + ‘, you will race at 12:30 pm.’)
} else if (age = 18){
console.log('Racer number ’ + ${raceNumber} + ‘, please see registration desk.’
};

Hello @ryanchipeniuk5549113, welcome to the forums! When you write

should it be the assignment operator (=) or the equality operator (===) when you write earlyReg=true?

Currently, using the assignment operator, after this if statement, earlyReg will always be true, since you assign it to true inside the if block.

1 Like

thank you muchly, i just realized i never sent a thanks when you helped with this :slight_smile:

1 Like