Wherefore art thou-passed

If we pass the challenge the output is only [object Object] the question is how to get the object’s properties? like first or last?


function whatIsInAName(collection, source) {
  let srcKey = Object.keys(source);

  return collection.filter();
}

console.log(whatIsInAName([{ first: "Romeo", last: "Montague" }, { first: "Mercutio", last: null }, { first: "Tybalt", last: "Capulet" }], { last: "Capulet" }));

Your browser information:

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

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

is it the correct way to store it in var and then var[0].first? I’ve done it this way

Yes, that’s how you would access a value in an object in an array.

This will return an array of objects and that’s probably why it’s being translated into [object Object]

1 Like

[object Object] is just what it looks like when you try to log an object to the console. If you want to print an object to the console in a useful way, use JSON.stingify().

1 Like

Thank you so much bros