Why does it return [undefined, undefined, undefined]
right now? What am I doing wrong?
How do I compare the key-value pairs in two objects? I’m probably not understanding that.
Your code so far
function whatIsInAName(collection, source) {
var arr = [];
// Only change code below this line
arr = collection.map(elem => {
if (Object.entries(source).includes(elem)) {
arr.push(elem);
}
})
// Only change code above this line
return arr;
}
console.log(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 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.89 Safari/537.36 Edg/84.0.522.40
.
Challenge: Wherefore art thou
Link to the challenge: