Intermediate Algorithm Scripting - Wherefore art thou

Tell us what’s happening:
I guess mistake somewhere in the if condition, can’t figure out where exactly.
It’s working for first two test cases, for others… it’ giving too big input, like checks are not strict enough, I can’t understand why checks are not strict enough.

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

for (let item of collection) { // need for.. of >>> it's array of objects
  for (let key of Object.keys(source)) { //need for... of >>> it's array
    if (!item.hasOwnProperty(key) || item[key] != source[key]) {


// Only change code above this line
//console.log(arr);//tests only
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/ Safari/537.36

Challenge: Intermediate Algorithm Scripting - Wherefore art thou

Link to the challenge:

This implementation needed some boolean flags.
Plus the pushing line was placed incorrectly.

To moderators: if I figured out issue on my own, it’s better to delete post or simply mark it as solved?

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