Tell us what’s happening:
I need some help with this challenge. What am I doing wrong?
Your code so far
function whatIsInAName(collection, source) {
// What's in a name?
var arr = [];
// Only change code below this line
var sourceKeys = Object.keys(source);
collection.filter( coll => {
sourceKeys.every( k => {
coll.hasOwnProperty(k)
&& coll[k] === source[k]
&& !arr.includes(coll)
&& arr.push(coll)
});
});
// 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 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3652.0 Safari/537.36
.
Link to the challenge: