feels like i’m missing something guys need a little bit of help
function whatIsInAName(collection, source) {
var arr = [];
// Only change code below this line
let newArr=[];
Object.values(source).forEach(value=>{
newArr.push(value);
})
for(let i=0; i<collection.length;i++){
for(let prop in collection[i]){
if(newArr.indexOf(collection[i][prop])>=0){
arr.push(collection[i]);
break;
}
}
}
// Only change code above this line
return arr.filter(object=>Object.keys(object).length>=newArr.length);
}
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 }));
console.log(whatIsInAName([{ "apple": 1, "bat": 2 }, { "apple": 1 }, { "apple": 1, "bat": 2, "cookie": 2 }], { "apple": 1, "cookie": 2 }));
console.log(whatIsInAName([{"a": 1, "b": 2, "c": 3}], {"a": 1, "b": 9999, "c": 3}));