Wherefire art though


function whatIsInAName(collection, source) {
  // What's in a name?
  var arr = [];
  var sourceProp = Object.getOwnPropertyNames(source);
  
  for(var j = 0; j < sourceProp.length; j++){
  for(var i = 0; i < collection.length; i++){
  
   
    if(collection[i].hasOwnProperty(sourceProp[j]) && collection[i][sourceProp[j]] == source[sourceProp[j]]){
    } 
    arr.push(collection[i]);
   }
 }

}

whatIsInAName([{ "a": 1, "b": 2 }, { "a": 1 }, { "a": 1, "b": 2, "c": 2 }], { "a": 1, "b": 2 });

I feel like I am getting close to the answer. I cant seem to pass the last two tests for this challenge. I would really appreciate any tips or steps to the right direction. Thank you in advance.

I have indented your existing code to make it more readable and to clearly see the code blocks (see below). See my comment/question regarding the if statement.

function whatIsInAName(collection, source) {
	// What's in a name?
	var arr = [];
	var sourceProp = Object.getOwnPropertyNames(source);

	for (var j = 0; j < sourceProp.length; j++) {
		for (var i = 0; i < collection.length; i++) {
			if (collection[i].hasOwnProperty(sourceProp[j]) && collection[i][sourceProp[j]] == source[sourceProp[j]]) {
			  // what was the purpose of this if statement, if you are not going to do anything inside it?
			}
			arr.push(collection[i]);
		}
	}
}