Consider the following code:
var sentences = [
\'Lorem ipsum dolor sit amet, consectetur adipiscing elit.\',
\'Vivamus aliquet nisl quis
You should do this without jQuery, it may not be as "pretty" but there's less going on and it's easier to do exactly what you want, like this:
var sentences = [
'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
'Vivamus aliquet nisl quis velit ornare tempor.',
'Cras sit amet neque ante, eu ultrices est.',
'Integer id lectus id nunc venenatis gravida nec eget dolor.',
'Suspendisse imperdiet turpis ut justo ultricies a aliquet tortor ultrices.'
];
var words = ['ipsum', 'amet', 'elit'];
for(var s=0; s -1) {
alert('found ' + words[w]);
return;
}
}
}
You can try it out here. I'm not sure if this is the exact behavior you're after, but now you're not in a closure inside a closure created by the double .each() and you can return or break whenever you want in this case.