# I don't know what's wrong with my code (race day project)

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

var registeredRunner = true;

var runnerNumber = 50;

if (registeredRunner = true || runnerNumber > 18) {
raceNumber += 1000 ;
}

if (runnerNumber > 18) {
console.log(`Runner number \${raceNumber} will race at 9:30.`);
} else if (runnerNumber > 18 && registeredRunner != true ) {
console.log(`Runner number \${raceNumber} will race at 12:30.`);
}
``````

I can’t get the second case values even when I change `registeredNumber` to `false`

Hello @wall1id. Before explaining what is wrong, you might want to take a look at these:

Specifically, the equal signs. What do equality operators look like in JS? Are they `=`, or is that something else?

Now, for the logic:

Here, you’re basically saying: ‘if the runner is over 18, do something.’ In the `else if`, you’re saying: ‘if the runner is over 18 and something else, execute some code.’ But that can never run, because the first condition `runnerNumber > 18` as already been checked by the above statement. So if that statement does not execute, then neither will the `else if`, as `runnerNumber` would not be above `18`.
I hope this helps!

1 Like

Thanks! now can see how illogical it is. I forgot to add another condition to the `if` statement:

``````if (runnerNumber > 18 && registeredRunner === true) {
console.log(`Runner number \${raceNumber} will race at 9:30.`);
} else if (runnerNumber > 18 && registeredRunner === false ) {
console.log(`Runner number \${raceNumber} will race at 12:30.`);
}
``````
1 Like

Hello @wall1id. Your logic is not flawed, but there is an easier way to do that:

``````if (object1 > condition1 && condition2) {
//code
}
``````

In the example above, we check if `object1` is greater than the condition. But since we are only checking to see if `condition2` is `true` or `false`, we only have to write it; we don’t have to go `condition2 === true`. In your case, that could be applied here:

``````if (runnerNumber > 18 && registeredRunner) {
console.log("abc");
}
``````

Here you check if `runnerNumber` is greater than `18`, and you check if `registeredRunner` is true.
Happy coding!

1 Like

Hey, Can you please help me with my code? I am not sure what is wrong in this.

let raceNumber = Math.floor(Math.random() * 1000);
let registeredEarly = true;
const runnerAge = ‘29’;
if (registeredEarly = true || runnerAge > 18){raceNumber += 1000;}
else {raceNumber;}
if (runnerAge > 18 && registeredEarly === true)
{console.log(`Your race number is \${raceNumber} and your race will begin at 9:30 AM`);}
else if (runnerAge > 18 && registeredEarly === false)
{console.log(`Your race number is \${raceNumber} and your race will begin at 11:00 AM`);}
else if (registeredEarly === true || registeredEarly === false && runnerAge < 18);
{console.log(`Your race number is \${raceNumber} and your race will begin at 12:30 PM`);}
else {console.log(`Help Desk!`)}

Hello, @cloud0256010789, and welcome to the forums. It’s a lot easier for others to read your code when it retains its original format. See How do I format code in my posts?

Consider whether the following expression evaluates to truthy or falsy.

``````const age_num = 29;
const age_string = '29';
age_num === age_string; //true or false?
``````