Javascript- only alert works inside function
<p>I have a function inside a constructor of <code>Module</code> called <code>areValidConstr(args)</code>, which in turn uses another function isInRange that is passed as an argument in the constructor. There is a problem with the if statement inside <code>areValidConstr</code>. Only the alert statement works and the <code>return false</code> does not work at all. And this function always returns true when I use it inside alert as <code>alert(areValidConstr(args));</code></p>

<p>Here is the code. Please help me! </p>

<pre><code>module.exports = Module;
function Module(args, isInRangeFunc) {

    var kvp = {};

    /**
     * Checks if value is in range for property prop
     * @returns bool true if prop is in range, false if not
     */
    var isInRange = function(prop, value){
        if(prop === "args") return true;
        return false;
    };

    if(!(isInRangeFunc === undefined) &amp;&amp; (isInRangeFunc !== null))
        isInRange = isInRangeFunc;

    /**
     * Checks if all arguments are valid and in range
     * @returns bool true if all props are in range, false if not
     */
    var areValidConstr = function(args){

        for( var key in args){
            if(!isInRange(key, args[key])) 
            {
                alert(key);
                return false;
            }
        }

        return true;
    }

    areValidConstr(args); 
}
</code></pre>

<p>Here is the code of the child class.</p>

<pre><code>module.exports = Module;

var SuperClass = require("framework/service/displayedData/ParameterizedDisplayedData");
Module.prototype = new SuperClass;
Module.prototype.constructor = Module;

function Module(args) {
// ************************************************************************ 
// PRIVATE VARIABLES AND FUNCTIONS 
// Only priveleged methods may access
// *********************************************************************** 
/* Declare private in the following way */
function isInRange(prop, value){


if(prop === "EventName" || prop === "Description" || prop === "RoomName"|| prop === "BuildingName"){
    if(TypeUtil.is_String(value)) return true;  
}

if(prop === "StartTime" || prop === "EndTime"){
    //TODO What are the bounds for valid time?
        if(Object.prototype.toString.call(value) === "[object Date]"){
            return true;
        }
}

return false;
}
SuperClass.call(this, args, isInRange);

};
</code></pre>
