Wherefore art thou JD help

Tell us what’s happening:

I currently get 4/6 but when matching the bottom one and the 3rd from bottom they’re incorrect,
I think that’s because I’m not checking if the objects are equal to each other?

I’m not sure how to go about checking that the objects are equal to each other to solve this?

Your code so far

function whatIsInAName(collection, source) {
  // What's in a name?
  var arr = [];
  // Only change code below this line
var keys = Object.keys(source);

  collection.forEach((obj) => {
    for(var i = 0; i < keys.length; i++)
      var prop = Object.getOwnPropertyNames(obj);
      if(prop.length >= keys.length) {
        if(!obj.hasOwnProperty(keys[i]) || obj[keys[i]] !== source[keys[i]]) {
  // Only change code above this line
  return arr;

// whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });

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

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

 whatIsInAName([{"a": 1, "b": 2, "c": 3}], {"a": 1, "b": 9999, "c": 3})

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:69.0) Gecko/20100101 Firefox/69.0.

Link to the challenge:

You have several issues here. One such problem is you are supposed to be returning an array. Every place I see the return statement used, you are not returning an array. You need to first figure out when and what you should be returning. You really only need be returning a value one time.

But that’s used to short circuit the loop, I’m the fact it does a short circuit probably signifies that it’s bad

Remember as soon as any return statement is executed, the function immediately exits. If you do not specify a value after the word return, the value undefined is returned. If you want to stop a for loop but not exit the function, you can use the break key word.