CHALLENGE TROUBLE w/ Basic JavaScript: Introducing Else If Statements

Tell us what’s happening:
This is being returned to me with:
“You should have closing and opening curly braces for each
if else code block.”
I’m pretty sure I got those, and all the other requirements for this challenge are checked off, so not sure what’s going on.

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

testElseIf(7);

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36.

Challenge: Introducing Else If Statements

Link to the challenge:

If anyone knows I’d love to understand why this happens sometimes. I ended up just copying and pasting it from the hints, but it didn’t look like anything changed and passed me through to the next one.

Hello and welcome to the freeCodeCamp community~!

The code you have written is correct - however, the tests appear to be failing due to incorrect formatting (indentation and line breaks). I was able to get your code to pass by hitting Ctrl+Alt+F in the editor to format the code.

I have opened a GitHub issue for this problem. :slight_smile:

1 Like