title: Filtering array against all of another array
body: <p>The <em>$scope.categories</em> array is being populated from a multi-select element in AngularJS.</p>
  
  <pre><code>$scope.categories = ["Adventure", "Strategy"]
  </code></pre>
  
  <p>I need to compare this array against the categories array in the items array below:</p>
  
  <pre><code>$scope.items = [
      {
          title: "Star Wars",
          categories: ["Adventure"]
      }, {
          title: "Star Search",
          categories: ["Adventure", "Strategy"]
      }, {
          title: "Star Trek",
          categories: ["Adventure", "Family"]
      }, {
      title: "Star Wars",
      categories: ["Family", "Strategy"]
  }];
  </code></pre>
  
  <p>Both values in <em>$scope.categories</em> need to match the same values in <em>$scope.items.categories</em>, for the object to be pushed to an output array.</p>
  
  <p>With the resulting $scope.filtered array being (items<a href="http://jsbin.com/fuwajo/1/edit?js,output" rel="nofollow">1</a>):</p>
  
  <pre><code>{
    title: "Star Search",
    categories: ["Adventure", "Strategy"]
  }
  </code></pre>
  
  <p>I have the logic until the loop needs to reiterate... but how?</p>
  
  <ol>
  <li>I am looping through <em>$scope.categories</em></li>
  <li>Then looping through <em>$scope.items</em> </li>
  <li>Then looping through <em>$scope.item.categories</em> array of each object.</li>
  <li><p>Then I am comparing the <em>$scope.categories</em> value against the value of <em>$scope.item.categories</em></p>
  
  <pre><code>for (var i = 0; i &lt; categories.length; i++) {
    for (var j = 0; j &lt; items.length; j++) {
      for (var k = 0; k &lt; items[j].categories.length; k++) {
        if(categories[i] == items[j].categories[k]) {
          console.log("The value of " + categories[i] + ", matches " + items[j].categories[k]);
        } else {
          console.log("The value of " + categories[i] + ", is not a match");
        }
      }
    }
  }
  </code></pre></li>
  </ol>
  
  <p>Here is a <a href="http://jsbin.com/fuwajo/1/edit?js,output" rel="nofollow">JSbin</a> example</p>