How to notify FCC of Typo in JS - Logical Order in If Else Statements

Hey all,
I was trying to find where I could submit a Typo that’s in the JavaScript Logical Order in If Else Statements Code - Here is the “correct answer” that worked with their bots:

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";

I got stuck on the code trying to match the statements because I was using the || operator, and it didn’t like that idea. I then looked more closely at the code they used in the demo, and figured out that they wanted me to give the answer as shown above. Given that the first statement is val < 5, the second operator is not “Less than 10”, it is >= 5 and <10.

Is there a place I can report this? Or am I totally wrong in my understanding of this code?

Thanks in advance!

Hi @KadenSmile !

Can you post your original code attempt along with the challenge link?

yup - give me a few mins to redo the code (I didn’t save it)

Looking at it again and trying to get the code to match my original, my main confusion was the statement “Less than 10”, because that would include all the <5 numbers that had been taken away by the "Less than 5 statement. To fix it, I would change the “Less than 10” statement to “Greater than or equal to 5 and less than 10” - this is likely really picky of me, but the wording got me stuck for a lot longer than it should have.

And random question - @jwilkins.oboe do you play oboe? if so, that’s awesome, I’m a fellow oboe player here!

Sorry for not posting the code I was trying, because it just wasn’t working properly and I don’t want to mess up my head with incorrect syntax, etc

1 Like

I was able to take a look at the lesson.

You don’t want to use the OR operator for the second condition.
you want to say in plain english, if the number is greater than or equal to 5 and less than 10.

If you translate that to code, then you would have to use the && operator.
That second condition will cover the numbers 5-9.

make sense?

Very cool :slight_smile:

Bear in mind, because the if branch captures those values less than five, the else if that follows won’t receive any value less than five. We have implicitly filtered those values out, so we can expect that any value bypassing that initial if must be greater than five… And potentially less than ten.

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