I've read in this Q&A that using continue
statements in loops should be generally avoided. Is the rule worth sticking to for the code below? If yes, what would be the best way to refactor it to get rid of them?
for (property in formInput) {
if (!formInput.hasOwnProperty(property) || property === "Id") {
continue;
}
if (property.slice(-3) === "_Id") {
setMagicSuggestFromFormInput(property);
continue;
}
if (property.slice(-3) === "_bl" && formInput[property] === true) {
$("#" + property).prop("checked", true);
continue;
}
$("#" + property).val(formInput[property]);
}
Edit: If you think the loop has to be refactored, besides indicating on how it can be done, could you please tell me why you consider the proposed refactoring a better design choice?