2
I have the following code snippet, which is executed when trying to insert an item into $scope.items{}
:
$scope.items.forEach(function(item, i) {
if (item.codigo == $('#codigo').val()) {
item.quantidade = parseInt(item.quantidade) + parseInt($('#quantidade').val());
return;
}
});
However, if the condition is met, the return
does not interrupt the rest of the code.
Outside the forEach
, the return
works normally, preventing the rest of the function from continuing to run.