Implement a Matching Object Filter - Implement a Matching Object Filter

There’s always something new to move on to.

The smaller pieces of each challenge will repeat in new ways. You will always be filtering or matching things going forward, so I don’t see that much advantage in coming back and redoing old challenges.

These challenges often require something to be solved in a particular way to implement some specific learning goal which might not be as relevant later.

you know, once i back to resolve challenge that i had solved in the paste,
i forgot how to solve it and it challenged my mind again,
and i needed to ask for help on the forums too,
but i will do it in one option, when i get despair of solving something hard that iam stuck in,
thanks for your valuable advice :slight_smile:

Hi, I just solved this problem, and wanted to take a look at other people solutions. I guess they took away that feature. However, you are very close to getting the answer don’t give up. Also this a very useful tool MDN. I spent a lot of time here and on YouTube for questions. But in your for loop of the obj do a nested loop test using your source keys! For each object you will be looping through the source keys and checking if the object value accessed with the source keys matches the source object value accessed with its source key if that makes sense.

Mod Edit: CODE REMOVED

After you figure out this solution please take some time to study how to break down coding problems. I need to do this also actually. Seeing the responses made me realize this. Also learn how/ don’t be afraid to google questions and search topics on your own. I saw people mention how you don’t need to join method, and you replied you don’t know how to compare if you don’t convert an array to a string. All you have to do is google how to compare objects/ array and you will find forums/ articles that will help you. Don’t underestimate the power of googling lol. Anyway Coding is hard!!! I struggle to explain what I know and what I don’t know so I hope I don’t confuse you even more. I am still learning myself. Good luck!!!

Thanks for your time and guidence, i really appreciates your efforts to help me,
you know i was thinking of that way, but the keys and the values are always arrays
i will try to cut this problem into smaller pieces following your hints,
wish me good luck :slight_smile:

ok thanks, i am not good really in planning,
but it’s learnable even it’s hard, i will try to give it my best,
was you 5 years out of fCC and just come back ?

Its okay. I feel off once I started my job but recently started back up again. The course is set up differently now then it is in the past .

Hi SamehCode01.

First, I want to provide some encouragement. I am an “old-timer”, as one might say, and although I “know” JavaScript, I wanted to get my skillset modernized and possibly drop some cruft from my brain. (The VAR replacements and reasoning have already improved me). However, I also was totally stumped when I encountered this challenge and had to step back and try several things to get it solved. I share this to demonstrate that even professional programmers hit walls. You are not alone, and it is NOT uncommon at all to encounter challenging tasks. It is actually quite normal.

Secondly, although you may be unsure, @Teller and @JeremyLT are doing you a GREAT service in pressing and pushing you to do something that, unfortunately, only good developers do today: problem-solve instead of “find the answer”. Problem-solving requires writing the problem in front of your face and making your brain solve each tiny piece. I cannot tell you how many times I have seen developers get stuck because they could not “find the answer” on the Internet, only to get the great AHA moment when a few simple questions are put to them. It might appear to be a subtle comparison between solving the problem and finding the solution to the problem, but it is significant factor between junior and lead developers.

Lastly, as I had the same issue as you and seeing that you have wrestled with this for a few weeks now, I wanted to share my notes (aka plan) that I had drafted after I made the bad assumption that this challenge was “supposed to be” short like the one-liner from the previous challenge. Never assume. :wink: Please trust me when I say this mental exercise will not only make you a better programmer but a faster problem-solver. Try to completely ignore whatever language you are writing in to solve the problem, and just focus on the basic step-by-step tasks (i.e., algorithm) you need to execute. The plan DOES NOT care about the programming language.

Sorry, one last thing. There is no wrong or right answer. There is working code and non-working code. Code can be refactored and improved, but ultimately working code of 20 lines and working code of 1 line have the same thing in common: they work. Don’t get hung up in perfection. Refactoring comes later, and I bet many here would agree they have created solutions faster by writing their long straight-from-the-plan version first and then translating to code and then refactoring, over perfect short code that took forever to conceptualize in their mind and actually write.

Anyway, enough back-slapping. Time to hit the field. :slight_smile:

/*

My function's algorithm/steps/plan (pseudocode)

- Create an empty array called "matches" to store objects that have
  the same properties (and property values) as the source object.
  (This will satisfy requirement 2).
- Iterate through each object of the objects array, and
  - Test whether all the source object properties exist in the
    object under test (i.e., the object of this iteration).
    - If a test fails, continue (skip) to the next object
    - NEW: Test whether the source object property value matches
      the value of the obj property under test.
      (See DELETED below for explanation of "NEW")
      - NEW: If the test fails, continue (skip) to the next object
  - If no test failed, then add this object to the "matches" array
    (because the object has at least the same properties as the
     source object)
- DELETED: Next, I need to iterate through the "matches" array
  (objects that at least have the same properties as the source
   object) to test whether they have the same property VALUES.
  - DELETED: Test whether the source object property values match
    the property values of the object under test (which means I
    would have to start another iteration through what I already
    did so ... drop this idea, and instead check for the value in
    the iteration above when I get a successful property match.)
- Return the matches array (it will still satisfy requirement 3
  if I was not successful in finding any matches).

*/

i think i was in need to this post long long time ago,
thanks very much for the whole post,
i really notice the improvment of my coding level even iam still weak,
but this words encourage me much,
thanks so much for so .
even i stopped working on the lab, i was continue the curriculum
and continue learning,
i finished my final js exam and waiting for the certification
time to back to the unsolved challenges for me
i’ve some of 'em not solved yet like >> fibonnacci function <<
thanks again very much for supporting and encouraging me <3

and as you said, time to hit the field :slight_smile: