I've used a "breakout" pattern for this:
$(sentences).each(function() {
var breakout;
var s = this;
alert(s);
$(words).each(function(i) {
if (s.indexOf(this) > -1)
{
alert('found ' + this);
return breakout = false;
}
});
return breakout;
});
This works nicely to any nesting depth. breakout
is a simple flag. It will stay undefined
unless and until you set it to false
(as I do in my return statement as illustrated above). All you have to do is:
var breakout;
return false
statement(s): return breakout = false
Not too inelegant, right? ...works for me anyway.