In the plain javascript function. Both the values, min_chk and max_chk are true, but the if function still shows the alert. not able to figure why?
function Checkit(m,n){
return m>n;
}
var min_chk = Checkit(a,X);
var max_chk = Checkit(b,Y);
if ((min_chk === 'true') && (max_chk === 'true')){
...
} else {
alert('invalid range');
}
The
===operator returnsfalseif the operands on both sides have different types. The booleantrueand the string"true"have different types.You should change your check just to
Since
min_chkandmax_chkare already booleans, you don’t need to compare them directly withtrue.