Consider the following code:
var sentences = [
\'Lorem ipsum dolor sit amet, consectetur adipiscing elit.\',
\'Vivamus aliquet nisl quis
Unfortunately no. The problem here is that the iteration happens inside functions, so they aren't like normal loops. The only way you can "break" out of a function is by returning or by throwing an exception. So yes, using a boolean flag seems to be the only reasonable way to "break" out of the outer "loop".