Javascript Control Flow I NEED HELP!

HELP !! when I set regEarly to false, the output to the console is still from the if statements. I need it to execute the else if statement. The regEarly variable is truthy by default. When i set it to false it shouldn’t the else if statement execute instead ??

let raceNumber = Math.floor(Math.random() * 1000);
let regEarly 
let age = 23
if(regEarly = true && age > 18){
  raceNumber += 1000  
}
if(regEarly && age > 18){
  console.log(`Race starts at 09:30AM and your race number is: ${raceNumber}`)
}
else if(!regEarly && age > 18){
  console.log(`Race starts at 11:30AM and your race number is: ${raceNumber}`)
}
else if(age < 18){
  console.log(`Race starts at 12:30PM and your race number is: ${raceNumber}`)
}

Here’s a hint: Check out the comparison operators here and make sure the ones you are using do what you think they do: Expressions and operators - JavaScript | MDN

I figured it out dude. I removed the = true from my first if statement and that worked for some reason haha

Nice work! To explain what’s going on better, since you used one = sign instead of two in the first if statement, it was always setting regEarly to true. It was overwriting the false value.

If you want to check if two values are equal, you can use == or ===. That MDN doc has more info on why you’d use one over the other.

1 Like

thanks dude, much appreciated