I wanna sum the elements of an array, but not all. Let's say that my array is:
var example = [
{"id": 1, "value": 50, "active": true},
{"id": 2, "value": 70, "active": false},
{"id": 3, "value": 45, "active": true},
{"id": 4, "value": 50, "active": false}
];
What I need to do is sum just the values
of the elements with "active":true
.
There's a way to do that? Maybe is too simple, but right now, my brain is dead.
I'm using Javascript and AngularJs.
Thanx in advance.