Tell us what’s happening:
I’ve been working on the logic of this challenge on paper, and I like what I have in terms of code so far. However I’m stuck with regards to each object in the collection must match each key/value pair in the source object. I do realize that the code is incomplete.
Please give guidance as to what I can do to complete this code. Thank you.
function whatIsInAName(collection, source) {
var matchedObjects = [];
collection.forEach(function(objectArgument) {
var objectProps = Object.keys(objectArgument);
for (var key in source) {
if (objectProps.includes(key) && objectArgument[key] === source[key]) {
}
}
});
return matchedObjects;
}
whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
Your browser information:
Your Browser User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36
.
Link to the challenge: