title: Underscore.js .filter() and .any()
body: <p>I have an array of <code>event</code> objects called <code>events</code>. Each <code>event</code> has <code>markets</code>, an array containing <code>market</code> objects. Inside here there is another array called <code>outcomes</code>, containing <code>outcome</code> objects.</p>
  
  <p>In <a href="https://stackoverflow.com/q/10821657/1048572">this question</a>, I asked for a [Underscore.js] way to find all of the events which have markets which have outcomes which have a property named <code>test</code>. The answer was:</p>
  
  <pre><code>// filter where condition is true
  _.filter(events, function(evt) {
  
      // return true where condition is true for any market
      return _.any(evt.markets, function(mkt) {
  
          // return true where any outcome has a "test" property defined
          return _.any(mkt.outcomes, function(outc) {
              return outc.test !== "undefined" &amp;&amp; outc.test !== "bar";
          });
      });
  });
  </code></pre>
  
  <p>This works great, but I'm wondering how I would alter it if I wanted to filter the outcomes for each market, so that <code>market.outcomes</code> only stored outcomes that were equal to <code>bar</code>. Currently, this is just giving me markets which have outcomes which have <strong>some</strong> set <code>test</code> properties. I want to strip out the ones that do not.</p>