See this:
var x = function() {
if(true) {
return false;
}
return true;
}
if( x === false) {
alert("OK");
} else {
alert("Wrong");
}
Check Fiddle.
Why is it “Wrong”? Why does this function not return false as expected?
To call your function use
You were testing if the variable
xwas holdingfalse, instead of testing the returned value of the function contained in thexvariable.