Bug in Basic JavaScript: Introducing Else If Statements lesson

Tell us what’s happening:
So, it’s giving me an error unrelated to my code, an unexpected token when I try to run it. It looks like a spellcheck issue? It’s just a random space that spellcheck says is incorrect. It seems like a bug, unless my code is wrong anyway?

Your code so far

function testElseIf(val) {
if (val > 10) {
  return "Greater than 10";
} else if (val < 5) {
  return "Smaller than 5";
} else {
return "Between 5 and 10";


Your browser information:

User Agent is: Mozilla/5.0 (X11; CrOS x86_64 12871.76.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.103 Safari/537.36.

Challenge: Introducing Else If Statements

Link to the challenge:

You are missing a closing } for your function. Usually unexpected token means you’ve forgotten a bit of syntax.

Side note: This is why I always indent my function bodies so its easier to see this sort of mistake.

1 Like

“Unexpected token” almost always means that you’re missing a character: usually ", ', ), }, ] and sometimes ;. It means that there was a “token” (piece of syntax) before there should have been.

1 Like