[Solved] JavaScript indexOf greater than -1 false when it’s clearly not?


You’re comparing a string and a number. You’re concatenating the result of indexOf (which I assume is -1) to a string before you do your > comparison. This is equivalent to NaN > -1.

"1b-1" > -1 // => false

0

solved JavaScript indexOf greater than -1 false when it’s clearly not?