I have this array $scope.taxarr
and I am facing some value which is mention below.
$scope.taxarr = [];
for (var co = 0; co < count_item; co++) {
$scope.qty_amt = parseInt($scope.newData1[co].quantity) * parseInt($scope.newData1[co].rate);
$scope.tax_val1 = (parseInt($scope.qty_amt) * parseInt($scope.newData1[co].tax_value)) / 100;
$scope.taxvalue = parseInt($scope.newData1[co].tax_value);
$scope.taxid = parseInt($scope.newData1[co].tax_name);
$scope.loop = $scope.taxarr.length;
if ($scope.loop === 0) {
$scope.taxarr.push({
tax_id: $scope.taxid,
tax_name: $scope.taxvalue,
tax_amount: $scope.tax_val1
});
} else {
for (var i = 0; i < $scope.loop; i++) {
if ($scope.taxid === $scope.taxarr[i].tax_id) {
$scope.taxarr[i].tax_amount = parseInt($scope.taxarr[i].tax_amount) + parseInt($scope.tax_val1);
break;
} else {
$scope.taxarr.push({
tax_id: $scope.taxid,
tax_name: $scope.taxvalue,
tax_amount: $scope.tax_val1
});
}
}
}
console.log($scope.taxarr);
}
I have one array which allows me to check particular id in array object and I face some problem with my inner if ... else
part where I check my id if there match value it is update amount else push object as new record
I am working with loop and every time loop provide different array value and compare in if condition.
I need some method that help me find value directly in array object and return in True/False where can i perform my action