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 10.0; Win64; x64; rv:64.0) Gecko/20100101 Firefox/64.0.
Yup. Now you’re saying “if the value is greater than five, do this.” So suppose you have 12 - following your order, is 12 > 5? Yup. So that block of code runs and exits the if statement. - so the val > 10 clause never gets touched. The < or > was never the issue. It was the order of the values.