If else statements

I really don’t know what is going on. been stuck here for hours now, everything seems right yet my code is not running.

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

testElse(5);
console.log(testElse(4));
console.log(testElse(5));
console.log(testElse(6));
console.log(testElse(10));
  **Your browser information:**

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

Challenge: Introducing Else Statements

Link to the challenge:

  if (val > 5) {
    result = "Bigger than 5";
  }

  if (val <= 5) {
    result = "5 or Smaller";
  }

It looks like you have changed the result strings.

your code

the starting code

there is a small difference in the string
can you see it?


I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

No i didnt, the questions requested `testElse(4)` should return the string `5 or Smaller`

testElse(5) should return the string 5 or Smaller
and they both did when I ran the code. yet, I did not pass the test.

Your string

Original string

They look different to me :slight_smile:

I'm so sorry. Finally got the hang of it.

thanks for pointing out, would have been staring without a breakthrough


I appreciate a great deal.

Typos happen to all of us.

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