# Javascript- Logical Order in if Else Statement

hi EveryOne!
everyone stuck in this exercise ,

what’s wrong in this code?
only two challenges pass
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);
``````

look at your code again!

the problem is in the if and else statement evaluation ,

You can post solutions that invite discussion (like asking how the solution works, or asking about certain parts of the solution). But please don’t just post your solution for the sake of sharing it.

We have set your post to unlisted. Thanks for your understanding.

hey @ArielLeslie
can i post like this or not?

Sorry. Your post confused me. I thought that you were sharing a working solution. Reading it again, I see that you were asking for help. I will re-list it.

If you take a look at the first two if conditions you should be able to figure out what you need to change. Any value that is less that 5 will go through the first condition only and never reach the second as any value less than 5 is also less than 10. So you could either reverse these two statements to first check if its less than the smaller number (in this case 5) or put a logical ‘&&’ in the first statement stating (val < 10 && val > 5).

Personally, I would test for greater than 10 first, then for greater than 5 and the rest can fall under the last category of less than 5.

I would look at the order of my statement.