I currently face a problem, it may be very simple but I found nothing in my research...
I want to check (in JavaScript) that a variable is a number, and if it is higher than 100 or lower than 0.
I tried this :
if ((returnValue > 100) || (returnValue < 0) || (typeof returnValue != 'number')) {
//not correct
} else {
// let's do some stuff here
}
But it doesn't work... When I put for example the number 50 (which is good), happening in the "if" and not in the "else" as expected !
So I did :
if ((returnValue > 100) || (returnValue < 0) || (isNaN(returnValue)))
and then I noticed that it perfectly worked !
I know too I could split that in two parts , firstly testing if the variable is a number and then if it is greater than 100 or less than 0, but this is not what I am currently looking for ;)
Could you please explain me why the first try doesn't work (and/or make it work) ?
Thanks !