Wherefore art thou-keep-up

What else is needed or what I haven’t added I’ve got stuck… help me
I filtered the collection and looped the source then checked if not obj in collection is equal to the one(s) in the source return false else return true
And the output is only an empty []


function whatIsInAName(collection, source) {
  // What's in a name?
  var arr = [];
  // Only change code below this line
  arr = collection.filter(function(prop) {
    for (let ky in source) {
      if (prop[source[ky]] !== source[ky]) {
        return false;
      }
      else {
        return true;
      }
    }
  })
  
  // Only change code above this line
  return arr;
}

console.log(JSON.stringify(whatIsInAName([{ a: 3, b: 4 },{ a: 5, b: null },{ a: 7, b: 8 }],{ b: 8 })));

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:65.0) Gecko/20100101 Firefox/65.0.

Link to the challenge:
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/wherefore-art-thou

take a closer look at the above, ky is the property of object prop you are interested in , yet you are searching for a value in source that doesn’t exist as a property in prop, doing that simple fix however will only pass the solutions partially, the other part is to also look and match for the values of the keys…

2 Likes

Thank you so much done

source[ky] !== prop[ky];