The working javascript snippet below does not include validation as it is only being used for learning purposes. However, I am not understanding the flow of events after variable 'isBetween' is defined within the buildBoundDetector() function. Why does passing a number through variable 'f' work?
function buildBoundDetector( lowerBound, upperBound ) {
var isBetween = function(number){
if(lowerBound <= number && number <= upperBound){
return true;
}
return false;
}
return isBetween;
}
var f = buildBoundDetector( 1, 100 );
f(45);