I have this type of object
var array = [
{ "foo": 1, "bar": 2, "baz": 3 },
{ "foo": 1, "bar": 2, "baz": 5 },
{ "foo": 1, "bar": 2, "baz": 4 },
{ "foo": 2, "bar": 1, "baz": 3 },
{ "foo": 2, "bar": 1, "baz": 7 },
{ "foo": 1, "bar": 3, "baz": 4 }
]
and If 'foo' and 'bar' key values are same then choose key 'baz' greater value and remove other objects.
like this
[ { "foo": 1, "bar": 2, "baz": 5 },
{ "foo": 2, "bar": 1, "baz": 7 },
{ "foo": 1, "bar": 3, "baz": 4 } ]
I tried this solution but it's not working for me. This question is not like my question.
So, what is the solution in underscore/lodash library or in javascript only.