both if/else logic execute in sequence without a return false added but when a return false is added, it works as normal, either if or else is executed but the code below it does not it executed, which is a problem..
var TL = {
displayInfo: function(sectionType, fileName)
{
if(sectionType == "sectionA")
{
sectionType = "ListA";
return false; // works as normal with this line
}else
{
sectionType = "ListB";
return false; // works as normal with this line
}
// additional below that is not being executed when I add the return false in the if/else logic
}
};
When I remove the return false statement in each if/else, both if/else execute. I have additional code in this method below the if/else logic that I would like to execute.
The
returnstatement takes the execution to the end of function and no code statement after return is executed. If you are returning false in bothifandelsethen take the return statement out ifif-else.If you have to return both false and true from condition if-else then you can use a variable to assign the return value. I have made a demo for your understand and practice, here