Wherefore art thou exercise, I am trying Object.entries

Tell us what’s happening:
Describe your issue in detail here.

I am trying to solve this problem since 2 days, Can anyone please tell me whats wrong with my code here?

Your code so far

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

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

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

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:93.0) Gecko/20100101 Firefox/93.0

Challenge: Wherefore art thou

Link to the challenge:

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

1 Like

You might want to check what you’re trying to include - i might console.log() both the one variable, and Object.entries(source[j]) and see if what you’re asking makes sense.

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