Logical Order in If Else Statements Understanding

Makes no sense - what’s wrong with this?Not sure I understand

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

Your browser information:

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

Link to the challenge:

If a value is less than 10, it will also be less than 5, so your else if is never going to execute. Remember that a function exits as soon as you hit a return.

1 Like