Then remove the if key
var sum = 0;
$scope.sample.forEach(function(value,key){
sum = value.num + sum
console.log(sum)
})
Then remove the if key
var sum = 0;
$scope.sample.forEach(function(value,key){
sum = value.num + sum
console.log(sum)
})