Logical Order in If Else Statements very hard not geting it

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

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:62.0) Gecko/20100101 Firefox/62.0.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/basic-javascript/logical-order-in-if-else-statements

Basically the challenge asks you to reorder the if statements^^
The first if statement is

 if (val < 10) {
    return "Less than 10";

followed by

 else if (val < 5) {
    return "Less than 5";

But if you pass the value 3 to the function it will be checked first of all against the first statement: is 3 < 10? true! So it returns ‘less than 10’, not ‘less than 5’ as you would expect ^^

Good luck! :slight_smile:

thank you for helping

1 Like