Tell us what’s happening:
I need some hints, I’m not getting it and not sure where to go or what to change. Thanks in advance!
Your code so far
const whatIsInAName = (arr, obj) => {
let objKeys = Object.keys(obj) // extract "keys" from obj
objKeys.forEach(i => { // iterate over obj
arr.filter(item => {
const keys = Object.keys(item) // extract keys from arr
console.log(keys, i)
if(keys.includes(i)){ // compare keys from arr and obj
return item // return the object in the array
}
})
})
}
console.log(whatIsInAName([{ "apple": 1, "bat": 2 }, { "apple": 1 }, { "apple": 1, "bat": 2, "cookie": 2 }], { "apple": 1, "cookie": 2 }))
// console.log(whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" }))
// console.log(whatIsInAName([{ "apple": 1, "bat": 2 }, { "bat": 2 }, { "apple": 1, "bat": 2, "cookie": 2 }], { "apple": 1, "bat": 2 }))
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36 Edg/144.0.0.0
Challenge Information:
Implement a Matching Object Filter - Implement a Matching Object Filter