I am getting an error that this has an illegal continue statement.
I have a list of words to check for form validation and the problem is it was matching some of the substrings to the reserved words so I created another array of clean words to match. If it matches a clean word continue else if it matches a reserved word alert the user
$.each(resword,function(){
$.each(cleanword,function(){
if ( resword == cleanword ){
continue;
}
else if ( filterName.toLowerCase().indexOf(this) != -1 ) {
console.log("bad word");
filterElem.css('border','2px solid red');
window.alert("You can not include '" + this + "' in your Filter Name");
fail = true;
}
});
});
The
continuestatement is fine for normal JavaScript loops, but the jQueryeachmethod requires you to use thereturnstatement instead. Return anything that’s not false and it will behave as acontinue. Return false, and it will behave as abreak:For more information, see the jQuery docs.