Intermediate Algorithm Scripting - Wherefore art thou

After seeing how elegant some of the codes were for the last challenge that I passed with clunky nested for loops, I dug down deep to try to be elegant. I think I am close. I could use some advice from here.

  **Your code so far**
function whatIsInAName(collection, source) {
let arr = [];
// Only change code below this line

for (let property in source) {
arr = collection.filter(test => test.hasOwnProperty(property));
console.log(arr);
}

// 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) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36

Challenge: Intermediate Algorithm Scripting - Wherefore art thou

Link to the challenge:

I think I need a second condition because I am filtering for matching properties regardless of the equality of the property values.

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