Tell us what’s happening:
I am done.I am just burned maybe i don’t know.I left this for the end since i had hard times to solve it.I managed to solve all the others through search and ask,but this one is still pain in my ass.It is working fine for the first two tests but then it doesn’t,and i know it doesn’t work because i should do something to iterate through all keys Array and check if each property of the object contains all of them,i just DON’T KNOW how to do it. I saw the recommended solutions but still i cant quite understand it.I will leave it for now,if someone can come up and explain this to me like i was 5 years old,i would appreciate it!Thanks for your time!
Your code so far
function whatIsInAName(collection, source) {
var arr = [];
let keys = Object.keys(source);
arr=collection.filter(item=>item[keys]==source[keys]);
console.log(arr);
return arr;
}
whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });
whatIsInAName([{ "apple": 1 }, { "apple": 1 }, { "apple": 1, "bat": 2 }], { "apple": 1 });
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/85.0.4183.83 Safari/537.36
.
Challenge: Wherefore art thou
Link to the challenge: