Tell us what’s happening:
I get three correct answer. But why?
Your code so far
function whatIsInAName(collection, source) {
let filter = source;
let result = collection.filter( x => {
for (let keys in filter){
if (x[keys] === undefined || x[keys] != filter[keys]){
return false;
}
return true;
}
});
return result;
}
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.13; rv:62.0) Gecko/20100101 Firefox/62.0
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/wherefore-art-thou