Could Not Figure the Solution

Tried a lot, but did not be able to find what’s wrong with the code.

Actually working but does not match the basic requirements.

  **Your code so far**

function whatIsInAName(collection, source) {
const arr = [];
// Only change code below this line
function whatIsAName(collection, source){

var searchKeys = Object.keys(source);

return collection.filter(function(obj){

  for(var i = 0 ; i < searchKeys.lenght ; i++){

      !obj.hasOwnProperty(searchKeys[i]) ||
    obj[searchKeys[i]] !== source[searchKeys[i]]
    ) {
         return false;
return true;

// Only change code above this line
return arr;

whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
  **Your browser information:**

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

Challenge: Wherefore art thou

Link to the challenge:

Is it intended to have nested function, that’s not called?

Why did you try to declare the function again inside the function?