SyntaxError: Unexpected token { in line no 10

SyntaxError: Unexpected token { in line no 10
0.0 0

#1

The code is correct but i am geting an error of statement.

SyntaxError: Unexpected token { at line no 10

function testElse(val) {
  var result = "";
  // Only change code below this line
  
  if (val > 5) {
    result = "Bigger than 5";
  }
  
  else  {
    result = "5 or Smaller";
  }
  
 
  // Only change code above this line
  return result;
}

// Change this value to test
testElse(4);

#2

i solved it. it was my mistake.


#3

I think it is because you have a condition in the else statement and it should not have one.


#4

I’ve edited your post for readability. When you enter a code block into the forum, precede it with a line of three backticks and follow it with a line of three backticks to make easier to read. See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.


#5

Thanks guys for the help