Wherefore art thou Challenge [help needed]

Tell us what’s happening:

I can’t seem to pass that last three tests.

Your code so far


function whatIsInAName(collection, source) {
  // What's in a name?
  var arr = [];
  // Only change code below this line
  arr = collection.filter(val => {
    for(let key in source){
      return source[key] === val[key];
    }    
    return true;
  });
  
  // Only change code above this line
  return arr;
}

whatIsInAName([{ "apple": 1, "bat": 2 }, { "bat": 2 }, { "apple": 1, "bat": 2, "cookie": 2 }], { "apple": 1, "bat": 2 });

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/wherefore-art-thou/

So I need to loop through all the properties in the source and have it passed for every val in the collection?

Got it! whoaaa! this was crazy…and thank you soo much!