Please tell me what’s wrong with my code:
Your code so far
function whatIsInAName(collection, source) {
var arr = [];
// Only change code below this line
var skeys=Object.keys(source);
console.log(skeys)
for(var i=0;i<collection.length;i++)
{
if(skeys.every(val=>Object.keys(collection[i]).indexOf(val)))
{
arr.push(collection[i]);
}
} console.log(arr);
// Only change code above this line
return arr;
}
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/83.0.4103.116 Safari/537.36.
Challenge: Wherefore art thou
Link to the challenge: