None of the solutions work based on the lesson

Tell us what’s happening:
None of the solutions works based on only editing the code above and below the comment lines.
How am I supposed to make this work if code below the line will not work
with the solution above the line?
“return arr” will not work.

Your code so far

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

// filter the collection
return collection.filter(function(obj) {
  return srcKeys
    .map(function(key) {
      return obj.hasOwnProperty(key) && obj[key] === source[key];
    .reduce(function(a, b) {
      return a && b;

// 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 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0.

Challenge: Wherefore art thou

Link to the challenge:

Hmm, all of the solutions work for me.

Right, the solutions do work, but I understand the frustration that they don’t fit the framework of the given function and the limitations of what lines you are to work on.

Sometimes the problems evolve and some of these solutions may have been written by people that got a little “creative”. But you should be able to get an idea what they are doing.

Why don’t you come up with a solution that fits the framework given and then submit it?

Oh, I see now. Those solutions can be modified to work with the starter code with some tiny adjustments.

I will have to do some research it looks like.
Ideas and keywords have been introduced that I
do not recall being discussed.
Thanks for the clarification.

Yeah, there are a lot of keywords and ideas flying around. One of the most important skills for a developer is knowing how to look things up. Seriously, I’m doing that all day - no one can remember all of this stuff.

I am always looking stuff up.
The issue I seem to run into is that I dont know what to
look up to come up with the solution I need.
You can’t find the answer if you dont know what knowledge you are missing.
It seems to defeat the point if I have to look at the solution, research the keywords, etc just to learn something from the current section.
Thanks for the help.
It is much appreciated.

You do not need to read the solution (and in professional development there are often not solutions to look up), but in professional software development we look stuff up all the time.
All of these challenges should be solvable with what you have seen so far, though some of the solutions include more advanced syntax for users who are using the challenges to practice new syntax they have recently learned.

Yeah, I know the feeling. I’m sure most coders can sympathize. It gets better over time.

1 Like

Ok. I am starting to put this together and understand the code.
I have another question related to the code.

For the line that is:
return obj.hasOwnProperty(key) && obj[key] === source[key];

For “key”, when does “key” equal “last: ‘capulet’” and when does
it equal “last:”…and how does it know?
It seems for the hasOwnProperty to work for an object, the “key” would
have to be equal to “last:”.
How does the code or functions know when key is equal to “last:” or
“last: ‘Capulet’”

Does my question make sense?

Reply to Jeremy…
Of all the solutions provided for the current lesson, there are ideas/keywords that have not been discussed.
I am not trying to be argumentative so please do not take it this way.
I have taken notes for each section writing down the material and the solution.
I have literally looked back through the notes and do not see all the idea/keywords for one of the solutions discussed.

I think these are the required lessons for the first solution, but maybe I missed one?

The intermediate can be pretty tricky. The challenges do not tell you which methods to use but instead leave you to choose how you want to tackle the task. There are lots and lots of ways to solve many of these.