My JavaScript exercise is stressing me

Tell us what’s happening:
I have already solved the exercise, but this message keeps appearing:
You should have closing and opening curly braces for each if else code block.

Don´t know what to do😥

  **Your code so far**
function testElseIf(val) {
if (val > 10) {
  return "Greater than 10";

} 
else if (val < 5) {
  return "Smaller than 5";

}
else if(val> 5 || val <10) {
  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/102.0.0.0 Safari/537.36

Challenge: Introducing Else If Statements

Link to the challenge:

What does your function return if you input 5?

1 Like

This is causing you to fail. What if val is 10? Or 5?

actually whilst the above issues are true, i think the test suite is not allowing a final else if, rather requiring a simple else
(i’m not 100%)

also check || versus &&

Yup. Both. The last if condition is wrong, but even if it was valid, the test expects a final else instead of an if else

You need an else statement to make the “between 5 and 10” return

Thanks for the tip, I´ll try it now

Oopps! I haven’t tried it yet😅

Grateful for you help

Thanks for helping too with script

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