Hello, I don’t understand why the code isn’t:
function whatIsInAName(collection, source) {
// What's in a name?
// Only change code below this line
let srcKeys = Object.keys(source);
return collection.filter(function(obj){
for (let i = 0; i < srcKeys.length; i++) {
if (!obj.hasOwnProperty(srcKeys[i]) || obj[srcKeys[i]] !== source[srcKeys[i]]) {
return false;
}
return true;
}
});
// Only change code above this line
return arr;
}
Your code so far
function whatIsInAName(collection, source) {
// What's in a name?
// Only change code below this line
let srcKeys = Object.keys(source);
return collection.filter(function(obj){
for (let i = 0; i < srcKeys.length; i++) {
if (!obj.hasOwnProperty(srcKeys[i]) || obj[srcKeys[i]] !== source[srcKeys[i]]) {
return false;
}
}
return true;
});
// 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_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/wherefore-art-thou