In C#, we have a .Sum(Predicate) method that lets you use a lambda expression to do a summation over a collection of objects. For instance, if I had the following set of objects (using JSON for simplicity)
[
{
"Id": 1,
"Sub": {
"Size": 1
}
},
{
"Id": 2,
"Sub": {
"Size": 3
}
}
]
And I wanted to get the sum of the sizes, I could do Sum(n => n.Sub.Size)
Is there a way to do something like this in javascript? I am really new (and weak) at the language and am having trouble performing a similar function. I am using jQuery, so I am open to that opening anything too.