I have a json response that returns an array. From the array I want to calculate the total of a variable in the json array. here is a snippet
$rootScope.getData = function () {
$http({
method: 'GET',
....
console.log(JSON.stringify(res.data.data));
returns
[{
"name":"John",
"age":30
}
{
"name":"Doe",
"age":30
}]
how to calculate the total age in the array to get 60 is a challenge