Introducing Else If Statements - missing {

Tell us what’s happening:

Am i crazy of is this else if statement missing the final { ?

In the example:

if (num > 15) {
return “Bigger than 15”;
} else if (num < 5) {
return “Smaller than 5”;
} else {
return “Between 5 and 15”;
}

Which there is clearly a { after the last else.

But the only way to pass the challenge is by omitting it…

What am I missing here?

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";
}

// Change this value to test
testElseIf(7);

Your browser information:

Your Browser User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/604.4.7 (KHTML, like Gecko) Version/11.0.2 Safari/604.4.7.

Link to the challenge:
https://www.freecodecamp.org/challenges/introducing-else-if-statements

If you want the braces, add one after the else, and a closing one after the last return line.

2 Likes

Oh, huh… So either one works? The last bracket closes the first one after (val)?

Sorry, this is my first time actually diving into Javascript and it’s a little confusing at times. So far I am really loving fCC though.

Thanks for the help!