Logical Order in If Else Statements please help

Logical Order in If Else Statements please help
0

#1

Tell us what’s happening:

Your code so far

function orderMyLogic(val) {
  if (val < 10) {
    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
orderMyLogic(4);

Your browser information:

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

Link to the challenge:


#2

What is your specific question?


#3

If you’re wondering why this doesn’t work like you intend it’s because you have no lower bound on the first condition. It should be

if ( val >= 5 && val < 10)

#4

Actually, the challenge does not want you to change the code in the if/else conditions. It simply wants you to change the order of the if/else/return statements. Flipping the first two conditions/returns is all that is needed.


#5

I should have clicked the link lol instead of guessing what the actual question was.