I have an array of event
objects called events
. Each event
has markets
, an array containing market
objects.
No need for Underscore, you could do this with native JS.
var events = [{markets:[{outcomes:[{test:x},...]},...]},...];
return events.filter(function(event) {
return event.markets.some(function(market) {
return market.outcomes.some(function(outcome) {
return "test" in outcome;
});
});
});
Yet of course you could also use the corresponding underscore methods (filter/select and any/some).