Feedback for my solution Intermediate Algorithm Scripting - Wherefore art thou

Tell us what’s happening:
Describe your issue in detail here.
is this a good way to solve this alogorithm that way ??

  **Your code so far**
function whatIsInAName(collection, source) {

for(let i =0; i < Object.keys(source).length;i++){
collection = collection.filter(item => item[Object.keys(source)[i]] == Object.values(source)[i]);

return collection; 

whatIsInAName([{ "apple": 1, "bat": 2 }, { "apple": 1 }, { "apple": 1, "bat": 2, "cookie": 2 }, { "bat":2 }], { "apple": 1, "bat": 2 }) 
  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36

Challenge: Intermediate Algorithm Scripting - Wherefore art thou

Link to the challenge:

Your solution is indeed working and looks good enough to me.

It looks better than my original solution for this, I can tell you that much.

Feel free to go to the guide page and compare your solution and their - that should give you more thoughts.

And, you can format your code a little bit for readability, maybe.

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