Basic JavaScript - Introducing Else Statements

Tell us what’s happening: I think there’s a bug in this lesson because i.ve written the required code yet its saying i’m wrong
Describe your issue in detail here.

Your code so far

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

Your browser information:

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

Challenge: Basic JavaScript - Introducing Else Statements

Link to the challenge:

Hi there and welcome to our community!

You should only change code between the lines indicated.

If you run your code you should see an error message in the console indicating that you have changed code elsewhere.

Is there a reason why you changed the let keyword to var? That may have been part of an older solution to this challenge but var has now been superseded by let and const.

All good, except you added code below this line. Did you add that extra comment?

You should have declare [var result = " "] ; to [let result = " " ;] just change the var keyword use let key word.

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