JavaScript - Introducing else if statements

The following code is giving me an error that is apparently after the code? But not something that I wrote and it doesn’t go away and if I try to delete anything past the end of the line nothing happens.

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


SyntaxError: unknown: Unexpected token (10:14)

8 | }
9 |

10 | testElseIf(7);
| ^

I tried to re do the lesson in Chrome, log out and log back in but it’s not going away

Please help

It looks like you have one too few closing }

Hi @JeremyLT you left one more tag to close which is the testElse(val) closing tag. You need to close it after the else closing tag.

I’m not sure why you @ed me, but that is what I was talking about when I said

to the OP

This sort of thing is why I recommend using proper indentation, to include indenting the entire function body. That makes missing braces far easier to catch.

You are right, it worked. Thanks a lot!

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