Basic JavaScript - Introducing Else If Statements

The console shows a syntax error in the line

testElseIf(7);

which I am not supposed to modify. It is saying the problem is the semi colon ; - this can’t be true. I can’t see anything wrong in my else if statements.

Grateful for any help.

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 (Macintosh; Intel Mac OS X 10.15; rv:106.0) Gecko/20100101 Firefox/106.0

Challenge: Basic JavaScript - Introducing Else If Statements

Link to the challenge:

Please Tell us what’s happening in your own words.

Learning to describe problems is hard, but it is an important part of learning how to code.

Also, the more you say, the more we can help!

it looks like you’re missing a curly brace } at the end to close the function .

Thanks very much - could not see that for looking!

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