[SOLVED] My "Wherefore art thou" code wont work inside nested loop but works outside loops?

when I take everything inside the nested loop and put it outside and changed the indices to actual values, then it will return something. When it’s inside the loops, it doesn’t do anything.

This outputs [];

function whatIsInAName(collection, source) {
  // What's in a name?
  var arr = [];
  // Only change code below this line
  var sourcekeys = Object.keys(source);

  for (var i = 0; i < sourcekeys; i++){
    for (var j = 0; j < collection.length; j++){
      // Checks to see if the object has the property and if their values are the same
      if (collection[j].hasOwnProperty(sourcekeys[i]) && collection[j][sourcekeys[i]] === source[sourcekeys[i]]){

  // Only change code above this line
  return arr;

This actually returns something:

if (collection[0].hasOwnProperty(sourcekeys[0]) && collection[0][sourcekeys[0]] === source[sourcekeys[0]]){
  return arr;

I worked on it for two hours and I didn’t catch that! :joy: thanks! I figured out the rest, too :slight_smile: