What are your thoughts on using nested if statements?
$scope.addToCart = function () {
if (flagA) {
if (flagB) {
if (flagC) {
alert('nononono!');
return;
}
}
}
executeAnotherFunction();
};
I'm working with the following function:
$scope.addToCart = function () {
var foo = 5;
if (someFlag == 'Y') {
alert('warning!');
return;
}
executeAnotherFunction();
};
I call this function somewhere in my code
ng-click = "addToCart()"
My goal is to exit the function if
someFlag == 'Y'
and avoid executing
executeAnotherFunction();
However, it seems that the function still executes it.
According to WebStorm, it suggests that the return
statement is unnecessary and could be safely removed.