Wherefore art thou doubt regaridng sollution

Hello everyone!

could someone help me understand why this option does not work? it makes sense in my head…

I have also tried replacing includes with hasOwnProperty() but the outcome is the same

function whatIsInAName(collection, source) {
var arr = [];
// Only change code below this line

for (let i=0; i<collection.length;i++) 
{if (collection[i].includes(source))
// Only change code above this line
return arr;

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; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36.

Challenge: Wherefore art thou

Link to the challenge:

Hi @as002 ,
.includes doesn’t work as collection[i] is an Object, not an array.
collection[i].hasOwnProperty(source) won’t work as source is an object and you need to specify a key (eg: first, last…) instead.

You could try extracting the keys from source using Object.keys

Hope this helps.

1 Like

Thank you very much, will try it :slight_smile:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.