If/else statements

Tell us what’s happening:
Describe your issue in detail here.

Not letting me pass what am i missing?

  **Your code so far**

function testElse(val) {
let result = "";
// Only change code below this line

if (val > 5) {
  result = "Bigger than 5";
} else {
  return "5 or smaller";

// Only change code above this line
return result;

  **Your browser information:**

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

Challenge: Introducing Else Statements

Link to the challenge:


5 or Smaller

You have a capitalization issue.

Also, I would either set result = ... or return in each branch of the if/else. I wouldn’t do something different in each half.

Ah dang, thanks.

Oh interesting. The challenge was already pre-written so I didn’t put the ‘result =’ there, I only changed the bottom half. FCC taught me to put ‘return’ since the beginning so that’s what I did.

Their example had a return, yeah. Its just a question of style if you want to do return vs result = here. Both work, but it definitely is best to do the same thing in each half of the if/else!

1 Like

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