Stuck with Wherefore art thou [SOLVED]

Stuck with Wherefore art thou [SOLVED]
0.0 0


Why is my console returning false? item[i] in has its property in source as far as i know
thank you :slight_smile:

function whatIsInAName(collection, source) {
  // What's in a name?
  var arr = [];
  // Only change code below this line
  function collector(value, index, item) {
    for (var i = 0; i < collection.length; i++) {
      if(item[i].hasOwnProperty(Object.keys(source)) === true) { 
  var result = collection.filter(collector);
  // Only change code above this line
  return arr;

    { first: "Romeo", last: "Montague" },
    { first: "Mercutio", last: null },
    { first: "Tybalt", last: "Capulet" }
  { last: "Capulet" }


What does Object.keys() return?


property key in source i presume


but in some cases it has the same result as comparing two identical vars … so it must be wrong… but i dont know to preplace it


Instead of presuming, look at the documentation. What does that function return? Does it make sense as an input for hasOwnProperty()? What argument does hasOwnProperty() expect?


string or property to test but that is not ideal with Object.keys() … i should understand the stuff im using …


You’re a little confused. Hope I’m able to clear your doubts.

The collector function accepts three arguments:
value: The current value in the iteration
index: the current index of the current value in the iteration
array: the entire collection itself
You don’t have to run a loop here
The individual elements are available in the value property
I have not taken this test. But the if condition here is definitely wrong.
You are trying to compre an array to a string.
Object.keys returns an array of keys belonging to the ‘source’ object.
hasOwnProperty accepts only a string/symbol in its parameter


thanks for explaining