Tell us what’s happening:
Why this code does not return the correct answer. Is it related to equality check if so can anyone please explain in detail what’s going on in this code to make it irrect
Your code so far
function whatIsInAName(collection, source) {
let srckey = Object.keys(source)
return collection.filter((obj)=>{
for(let i=0; i<srckey.length; i++){
if(obj.hasOwnProperty(srckey[i]) || obj[srckey[i]] === source[srckey[i]]) {
return true
}
}
return true
})
}
whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36
.
Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/wherefore-art-thou