Is there any better way to write the below code. So I want that if any of the row has invalid fields, I want to immediately return the result as "false" i.e. I do not want to execute the code or check for any further rows in the loop.
anyRowInvalid: function() {
var items = this.get('sectionInformation.items');
var isValid = true;
for (let i=0; i < items.length; i++) {
var gridItemObj = {};
Object.keys(items[i]).forEach(function(itemkey) {
if (typeof items[i][itemkey] === 'object') {
if ((items[i][itemkey].valid) && (items[i][itemkey].valid === false)) {
isValid = false;
}
}
});
}
return isValid;
},