Third chalenge Algorithm Scripting:Wherefore art thou

hello,
I’m tring to take some chalenge on freecodecam…trying to do the third exercise about section intermediate Algorithm…i’ve noted that only the first two case are done in my sucessfull completation and i’dont understant why in the other case it fails…my work looks like similar to the solution proposed but for some strange motive it seems not work…some one please could explain me why?because i did not be able to understand the motive.

here my code : Wherefore art thou

function whatIsInAName(collection, source) {
  // What's in a name?
  let arr = [];
  let keySource = Object.keys(source);
  for(let i=0;i<keySource.length;i++){
    for(let j=0;j<collection.length;j++){
      if(!collection[j].hasOwnProperty(keySource[i]) 
         ||
         collection[j][keySource[i]] !== source[keySource[i]]){ 
          false;           
       }else {
          arr.push(collection[j]);
       }
    }
  }
return console.log(arr) 
}
whatIsInAName([{ "apple": 1, "bat": 2 },
               { "bat": 2 },
               { "apple": 1, "bat": 2, "cookie": 2 }],
              { "apple": 1, "bat": 2 })

here the first solution freecode camp proposed :

function whatIsInAName(collection, source) {

  var srcKeys = Object.keys(source);

  // filter the collection
  return collection.filter(function(obj) {
    for (var i = 0; i < srcKeys.length; i++) {
      if (
        !obj.hasOwnProperty(srcKeys[i]) ||
        obj[srcKeys[i]] !== source[srcKeys[i]]
      ) {
        return false;
      }
    }
    return true;
  });
}

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

cheers

This is not doing anything. Maybe you meant to return the value false?

console.log statement have a return value of undefined, so you are returning the value undefined here.

yes in the first stament i’ve forgot a “return”…but now rechecking the code it seems not work…but it works until one hour ago…i’ll be check…