[
{
"id": 0,
"price": "100"
},
{
"id": 1,
"price": "50.95"
}
]
var json = '[{"id":0,"price":"100"},{"id":1,"price":"50.95"}]';
var data = JSON.parse(json);
function calc (arr) {
var sum = 0;
arr.forEach(function (item) {
var n = +item.price;
sum += n;
});
return sum;
}
var sum = calc(data);
console.log(sum);