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

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

#1

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


#3

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:


#4

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


#5

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…


#6

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


#7

Change ‘56’ to ‘55


#9

I suspect testLessThan(99) will fail…


#10

It actually ran through fine.


#12

I know, right?!

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


#14

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


#17

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


#18

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.