I have an array of this type
[ { 'a': 10, elements: [ { 'prop': 'foo', 'val': 10 }, { 'prop': 'bar', 'val': 25 }, { 'prop': 'test', 'val': 51 } ] }, { 'b': 50, elements: [ { 'prop': 'foo', 'val': 30 }, { 'prop': 'bar', 'val': 15 }, { 'prop': 'test', 'val': 60 } ] }, ]
I need to summarize the Val property when prop is equal to foo . So, I have to look for elements and get all the objects where prop is foo . With these objects, I have to summarize the Val property.
I tried using many combinations of _.find , _.pick , etc., but I am not getting the correct result. Can anybody help me?
source share