Basic JavaScript - Logical Order in If Else Statements

Tell us what’s happening:

Describe your issue in detail here.

Your code so far

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

orderMyLogic(4)

Your browser information:

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

Challenge Information:

Basic JavaScript - Logical Order in If Else Statements

:balloon:Hello! Welcome to the forum!

So, this is a bit of a tricky challenge. If you think about it a bit you will see that any value less than 10 will be caught by the first if clause. This means that a value less than 5 will never be caught by the else if clause.

Does this help?
Keep up the good progress!

Happy Coding! :slightly_smiling_face:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.