title: Check if any object in an array of objects contains all of the key/value pairs in another object
body: <p>I'm trying to write a function that looks through an array of objects (the first argument) and returns an array of all objects that contain all of the key/value pairs of a given object (the second argument).</p>
  
  <p>My code below works only if the <code>source</code> object (the second argument) contains one key/value pair. When the <code>source</code> object has two or more key/value pairs, the result isn't as expected.</p>
  
  <p>How to account for more than one key/value pair in the <code>source</code> object?</p>
  
  <pre><code>function findObjects(collection, source) {
    var result = [];
  
    for (i=0; i&lt;collection.length; i++) {
      for (var prop in source) {
        if (collection[i].hasOwnProperty(prop) &amp;&amp; collection[i][prop] == source[prop]) {
          console.log('Collection\'s object ' + [i] + ' contains the source\'s key:value pair ' + prop + ': ' + source[prop] + '!');
          result.push(collection[i]);
        } else {
          console.log('fail');
        }
      }
    }
  
    console.log('The resulting array is: ' + result);
    return result;
  }
  
  findObjects([{ "a": 1, "b": 2 }, { "a": 1 }, { "b": 2, "c": 2 }], { "a": 1, "b": 2 });
  
  // only the first object should be returned since it contains both "a":1 and "b":2
  </code></pre>