Basic JavaScript - Logical Order in If Else Statements

Tell us what’s happening:
Describe your issue in detail here.
im not really sure what im supposed to be doing here. switched the numbers around, it seems no marrwe what im missing one of the three targets

  **Your code so far**
function orderMyLogic(val) {
if (val > 5) {
  return "Less than 10";
} else if (val >= 11) {
  return "Less than 5";
} else {
  return "Greater than or equal to 10";

  **Your browser information:**

User Agent is: Mozilla/5.0 (X11; CrOS x86_64 14816.131.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36

Challenge: Basic JavaScript - Logical Order in If Else Statements

Link to the challenge:

The original code given was this ( I added line numbers so we can refer to them easier):

01 function orderMyLogic(val) {
02    if (val < 10) {
03      return "Less than 10";
04    } else if (val < 5) {
05      return "Less than 5";
06    } else {
07      return "Greater than or equal to 10";
08    }
09 }

In the original code, if we pass the value 4 for eg in as input what happens?
Let’s go through it line by line.

on line 01, val=4
on line 02, we check if 4 is less than 10, yes it is so
on line 03, we return the text “Less than 10”

Okay, so far that seems okay, but isn’t 4 also less than 5? We want to move the code around so that an input val of 4 will print out “Less than 5” instead.

So what should we change to do that?

thanks i wasn’t changing the return statements as well!!!

1 Like

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