LogicalOrder in If Else Statement

Tell us what’s happening:

Your code so far

function orderMyLogic(val) {
  if (val < 1) {
    return "Less than 10";
  } else if (val < 5) {
    return "Less than 5";
  } else {
    return "Greater than or equal to 10";

// Change this value to test

Your browser information:

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

Link to the challenge:

You are returning “Less than 10” when val is less than 1. I guess you meant 10 there.

Also, if the first if statement is true, it will not check the else statement. So if val is 4, the first if statement will return true (and thus return “Less than 10”) and it will not check the second statement to see if it is less than 5.

1 Like