I have a for loop that I want to exit like this:
function MyFunction() {
for (var i = 0; i < SomeCondition; i++) {
if (i === SomeOtherCondition) {
// Do some work here.
return false;
}
}
// Execute the following code after breaking out of the for loop above.
SomeOtherFunction();
}
The problem is that after the // Do some work here. statements executes, I want to exit the for loop but still want to execute the code below the whole for loop (everything below // Execute the following code after breaking out of the for loop above.).
The return false statement does exit the for loop but it also exits the whole function. How do I fix this?
breakstatement.