[Solved]"Intermediate Algorithm Scripting: Wherefore art thou" Issue

Hey, so I’ve been working on this problem and I am getting an intermediate result that confuses me. Here is my code:

function whatIsInAName(collection, source) {

  var arr = [];

  let sourcePropArray = Object.getOwnPropertyNames(source);
  arr = collection.filter(
    (objectElement) => {
      let count = 0;
      let propArray = Object.getOwnPropertyNames(objectElement);
      if(
        sourcePropArray.every(
          (x) => {
            propArray.includes(x);
          }
        )
      ) { 
        for(let property in source) {
          console.log(source[property]);
          if (source[property]===objectElement[property]) {
            count += 1;
            console.log(count);
          }
        }
      }
      if (count === sourcePropArray.length) {
        return true;
      } else {
        return false;
      }
    }
  )
  // Only change code above this line
  return arr;
} 

The following if statement always returns false:

     if(
        sourcePropArray.every(
          (x) => {
            propArray.includes(x);
          }
        )
      ) 

I have tested this in the console. Any insight into why this is happening would be appreciated. Thanks!

Your .every() callback function isn’t returning a value.

1 Like

Ahh man, it’s always the silliest stuff. I either need to use the return keyword or get rid of the inner brackets Thanks a lot for your help!