Can anyone explain why i am getting a ‘SyntaxError: Unexpected token else’ error on the console. Also note that if i remove the word else from the last code, its runs without an error. This is really suprising as I see nothing wrong with the code, only an inclusion of the word else leads to an eror message.
PS: you should try copying and pasting the code so you can see what I’m saying.
let raceNumber = Math.floor(Math.random() * 1000);
let earlyRegistration = true;
let runnersAge = 20;
if(earlyRegistration && runnersAge>18)
{raceNumber += 1000};
if (earlyRegistration && runnersAge > 18) {console.log(`You will race by 9.30am. Your race number is ${raceNumber}`)};
else if (!earlyRegistration && runnersAge > 18) {console.log(`You will race by 11.00am. Your race number is ${raceNumber}`)};