 # I need solution to let me proceed

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

``````

Hi can you provide us with more context so we can help you in understanding what’s wrong (which is what we should do, instead of handing over any solution)?
What is the challenge? What do you need to do?

the first statement that is true is the one executed

if you have a 4
it is less than 10, so you get the output “Less than 10”
but it is (also) less than 5, but this statement is not executed because the previous one is the one that executed

This is what should be my output (orderMyLogic(4) should return “Less than 5”)

Sir this is my code

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

This is what should be my output (orderMyLogic(4) should return “Less than 5”)

Sir this is my code

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

`val` is 4
if statements are evaluated in order
`val < 10` is true (it is the first condition met), so the statement is executed. your code returns `Less than 10`

considering this, you need to change something because 4 needs to return `Less than 5`

1 Like

sir that is why i’m here,what did i need to change
where at syntax

Like @ieahleen said, the conditions in your “if-else” statements are evaluated in the order you write them.
So with the current code the first condition is the one that triggers the return for numbers below 5.
A return makes the evaluation of the rest of the code in the function stop and gives back the number to whatever called the function.
You’ll want to change the order of the conditions, keeping the most restrictive as first.

Have follow your solution which i change the following condition but still not accepted
pls i want you to reveal me the code

Can you post your updated code?

you can manage it on your own without seeing the complete solution!

@walewahab, re-read the comments that explain why it is not working. If after that you still can’t figure it out, I encourage you take a bit of a break, take some fresh air, and go back to the problem in some minutes.
Sometimes, especially if we are tired, a break it’s all it takes in order to go back to the problem and solve it with “new eyes”.
We cannot give you the solution, you wouldn’t learn the concept otherwise.
Overcoming obstacles, either big or small, is what make us learn and it’s an important part of being a developer (considering that being a developer means that you’ll have to keep learning for the rest of your career, given the speed of growth of the industry).

Also if you want to see how your code behaves during its execution, copy it (preferably the one with a value less then 5) and paste it on this website http://www.pythontutor.com/visualize.html#mode=edit. Chose “Javascript ES6” from the programming language list and launch the visualization.
You’ll be able to move through the steps with the buttons under the slider on the left.

Hopefully having it visually available helps more.

Not sure I am up to speed - is there an issue? If so order like this:

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

boss…where have you been you keep me idle since morning i’m very grateful sir Thank you sir