Introducing Else If Statements - missing {

Introducing Else If Statements - missing {
0

#1

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:


#2

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


#3

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!