Whats the problem in this? I'm stuck and clueless

let raceNumber = Math.floor(Math.random() * 1000);
const earlyRegister = false;
let age = 12;

if (age > 19); {
console.log(‘ok’);
} else if(age < 19) {
console.log(‘not ok dude’);

}

Hey Meghan, welcome to the forums.

Sometimes it’s the little details. You can usually take a short break and then re-read your code carefully line by line to spot them.

What’s the difference between

if (age > 19); {

and

} else if (age < 19) {

?

4 Likes

Hey Meghan.
I believe what you’re asking is why you’re getting a syntax error in the console saying SyntaxError: Invalid or unexpected token. This is because you used ‘ instead of ’ or " around what is meant to be your string console.log('ok'). They look similar but if you look up close they’re different. Also, after if (age > 19) you put ;. After deleting this you won’t get a syntax error claiming there’s an “unexpected token else”. You only need { } after an if statement, not a ;. The code should now look like this.

let raceNumber = Math.floor(Math.random() * 1000);
const earlyRegister = false;
let age = 12;

if (age > 19) {
  console.log('ok');
} else if (age < 19) {
  console.log('not ok dude');
}

(Just a note for the future. When posting code in a question, you can select your code and click the icon </>. It just makes it easier to read.) Hope this helped. Let me know if it doesn’t.