Tell us what’s happening:
I’m only partially passing this challenge and would like pointers/guidance as what I can do to fix this wholly so it passes.
function whatIsInAName(collection, source) {
var matchedObjectProps = []; // an array to capture objects that match `source` key/value pairs
collection.forEach(function(objectArgument) {
var objectProps = Object.keys(objectArgument); // an array of object keys from `objectArgument`
for (var key in source) { // for each property defined in the `source` object
objectProps.forEach(function(prop) {
if (objectArgument.hasOwnProperty(prop) && objectArgument[prop] === source[key]) {
matchedObjectProps.push(objectArgument);
}
});
}
});
return matchedObjectProps;
}
whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
Link to the challenge: