Topic: Introducing Else Statements

Topic: Introducing Else Statements
0.0 0

#1

Tell us what’s happening:

Hi, can anyone help me with this exercise? I have changed the if else statement as shown below but seems something is wrong and i can’t identify what.

thanks
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:

Your Browser User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36.

Link to the challenge:


#2

You will need to ensure all your return to have exact result as what the tester needed.

All you missed was capital B and S.

“Bigger than 5” and “5 or Smaller”

Additionally, try to format your code to the clearest indentation, spacing etc.

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