I'm making a function that looks thru an array of the first argument and returns an array with all the objects that are matching the second argument. i dont know what is wrong with my code or how to fix it. i would appreciated it if you can help me
function whatIsInAName(collection, source) {
const arr = [];
// Only change code below this line
for (let i=0; i<collection.length; i++) {
if (source.hasOwnProperty(collection[i])) {
arr.push(collection[i])
}
}
// Only change code above this line
return arr;
}
whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });