I have lots of functions which is used for validations. Can I use same return varibale for all the functions?
function fn1() {
if () {..
first = true;
} else {
first = false;
}
return first;
}
function fn2() {
if () {..
second = true;
} else {
second = false;
}
return second;
}
function fn3() {
if () {..
three = true;
} else {
three = false;
}
return three;
}
$('#submitButton').click(function () {
var returnVal = true;
returnVal1 = fn1();
returnVal2 = fn2();
returnVal3 = fn3();
if (returnVal1 && returnVal2 && returnVal3) {
returnVal = true;
} else {
returnVal = false;
}
return returnVal;
});
Instead of these many variables like returnVal1, returnVal2 and returnVal3, can I use returnVal for all the function returns?
Can I use a single variable for all the function returns?
Thanks