After fetching data from the server using $http.Get, I have a function that calculates the total value. The total value comes out as negative (-370), which is correct. However, when I try to use this value to create an angular chart, I need to display it as a positive number. Can anyone help me with this?
Array.prototype.sum = function (prop) {
var total = 0
for (var i = 0, _len = this.length; i < _len; i++) {
total += parseInt(this[i][prop])
}
return total
}
$scope.totalCreadit = function (arr) {
return arr.sum("credits");
}
Thanks in advance!