HELP - JavaScript: Comparison with the Less Than Operator [Solved]

What on earth am I doing wrong?! 49 is less than 55, so it should return “55 or over,” right?

So that’s what I thought, too. (I realized this and tried before my original forum post.)

If I remove the value next to 99, I get another error:

And, if I add a number back in next to 99, any number, the error goes away:

Your second condition is breaking it. The code says ‘less than 56’ but the return statement says ‘under 55’

So when the test passes the value of 55, it thinks the number is ‘less than 56’ and returns the statement that 55 is under 55…

What you said makes sense, but I’m unsure of how to fix it.

Change ‘56’ to ‘55

2 Likes

I suspect testLessThan(99) will fail…

It actually ran through fine.

I know, right?!

I’m trying to figure out what the (val < 0, 99) syntax even means now…

I honestly don’t even know why I tried that? But it worked. The 0 could be any number and it still went through.

I was just reading that, but forgot that it would evaluate 99 as truthy.

I was reading it as if (val < 0 || val < 99) and it was still melting my brain!

Good pick up, @P1xt

The original challenge doesn’t have the final if statement, it just returns ‘55 or over’ for anything.

That way if FCC included tests for 100+ it would continue to behave reasonably.