Basic JavaScript: Logical Order in If Else Statements Help needed with passing one checkmark

Tell us what’s happening:

I’m supposed to make sure else if statements are in the right order, and they seemed to be so I ran the test and only one checkmark needs to be met, and I need help with that one, and what is orderMyLogic(7)?

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


Your browser information:

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

Challenge: Logical Order in If Else Statements

Link to the challenge:

What happens when you run


Is that what you expect?

How do I reach this checkpoint orderMyLogic(4) should return "Less than 5"?

Did you try reordering the if statements?

I changed the location of the second if statement to the else statement below it and it didn’t the fix the issue, also peculiar then I changed the if (val < 10) to if (val > 10), it become the opposite the two checkpoints become wrong and the one I’m trying to fix become correct.

What happens if (val < 10)? Remember that a return halts function execution.

I changed if (val < 10) to if (val < 5), return = "Less then 5", and did the same thing with the ten condition. And it fixed the issue.

1 Like

Exactly. The else if statement was never being hit because (val < 10) also covers (val < 5).

I know thank you, I need it to return “Less then five”, if it actually is less then five, not just less then ten, and changing the level between five and ten fixed the issue.

1 Like