HELP Wherefore art thou

Tell us what’s happening:
I need some help with this challenge. What am I doing wrong?
Your code so far


function whatIsInAName(collection, source) {
  // What's in a name?
  var arr = [];
  // Only change code below this line
  
	var sourceKeys = Object.keys(source);
	
 	collection.filter( coll => {
		sourceKeys.every( k => {
			coll.hasOwnProperty(k) 
				&& coll[k] === source[k] 
				&& !arr.includes(coll) 
				&& arr.push(coll)
		});
  	});
  
  // Only change code above this line
  return arr;
}

whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" });

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3652.0 Safari/537.36.

Link to the challenge:

What do you think this is doing?

I think it’s an object element from collection array… still confused

You’re using filter and every methods inappropriately. Both of them return something useful that should be stored somewhere. filter returns a subset of an input array and every returns a boolean that informs if all the array items satisfy a certain condition. Both of these methods are the right tools to solve the challenge, you just need to figure out how to use them properly.

Fair enough! :slight_smile: Thanks