Whats going ong with my code in JAVASCRIPT?

let raceNumber = Math.floor(Math.random() * 1000);
let registeredEarly = true;
let age = 19;
if ( registeredEarly && age > 18) {
raceNumber += 1000;
}
if (age && registeredEarly) {
console.log( "they will race at 9:30 am" ${raceNumber}. )
}
else if (age && registeredEarly) {
console.log( "they will race at 11:00am" ${raceNumber}. );
}
else if (!age && registeredEarly ) {
console.log("they will race at 11:00 am" ${raceNumber}.)
};
else if (age < 18) {
console.log('they will race at 12:30 pm is' : ${raceNumber}.)
};
else (age) {
console.log('Check your registration': ${raceNumber}.)
};

error bellow

home/ccuser/workspace/learn-javascript-U2P2/main.js:16
else if (age < 18) {
^^^^
SyntaxError: Unexpected token else
at createScript (vm.js:53:10)
at Object.runInThisContext (vm.js:95:10)
at Module._compile (module.js:543:28)
at Object.Module._extensions…js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.runMain (module.js:605:10)
at run (bootstrap_node.js:427:7)
at startup (bootstrap_node.js:151:9)

The semi-colon is an end of statement token so the interpreter stops parsing at that point.

1 Like

Master, I removed the semicolon and still showes error.

Remove all similarly located semi-colons. Also, did you see that you have the same conditional twice?

2 Likes

Thank you for taking your time to reply me

1 Like

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