Question
Why am I getting a SyntaxError: Unexpected token
error?
Answer
It is likely that you wrote your else if
/else
incorrectly. Make sure that your else if
s are between your if
and else
. In JavaScript you do not need an else
if you don’t want one but you cannot have an else if
before an if
or after an else
. Once you use else
, that’s it. The conditional branches following the original if
are done.