# Intermediate Algorithm Scripting - Wherefore art thou

**URL:** <https://forum.freecodecamp.org/t/intermediate-algorithm-scripting-wherefore-art-thou/604022>\
**Category:** Curriculum Help\
**Tags:** javascript\
**Created:** [April 12, 2023, 4:28pm UTC](https://forum.freecodecamp.org/t/intermediate-algorithm-scripting-wherefore-art-thou/604022 "2023-04-12T16:28:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tomboyo21](https://avatars.discourse-cdn.com/v4/letter/t/b4bc9f/32.png) [@tomboyo21](https://forum.freecodecamp.org/u/tomboyo21)\
**Post date:** [April 12, 2023, 4:28pm UTC](https://forum.freecodecamp.org/t/intermediate-algorithm-scripting-wherefore-art-thou/604022/1 "2023-04-12T16:28:03Z")

</div>

Am I right in thinking that if the boolean returns as true then it automatically puts the values into a new array? I’m not 100% sure I understand why booleans are used here.

**Your code so far**

```javascript
function whatIsInAName(collection, source) {
  // "What's in a name? that which we call a rose
  // By any other name would smell as sweet.”
  // -- by William Shakespeare, Romeo and Juliet
  const souceKeys = Object.keys(source);

  // filter the collection
  return collection.filter(obj => {
    for (let i = 0; i < souceKeys.length; i++) {
      if (!obj.hasOwnProperty(souceKeys[i]) ||
          obj[souceKeys[i]] !== source[souceKeys[i]]) {
        return false;
      }
    }
    return true;
  });
}

// test here
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/112.0.0.0 Safari/537.36`

**Challenge:** Intermediate Algorithm Scripting - Wherefore art thou

**Link to the challenge:**

> **[freeCodeCamp.org](https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/wherefore-art-thou)**
>
> Learn to Code — For Free

---

<div class="post-metadata">

**Author:** ![tomboyo21](https://avatars.discourse-cdn.com/v4/letter/t/b4bc9f/32.png) [@tomboyo21](https://forum.freecodecamp.org/u/tomboyo21)\
**Post date:** [April 12, 2023, 5:54pm UTC](https://forum.freecodecamp.org/t/intermediate-algorithm-scripting-wherefore-art-thou/604022/3 "2023-04-12T17:54:16Z")

</div>

Yes I think thats the one I mean. Okay thanks

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/freecodecamp/original/3X/e/1/e1c433102e34b46dfaa3e15d13ab9a514b127078.svg) [@system](https://forum.freecodecamp.org/u/system)\
**Post date:** [October 12, 2023, 5:54am UTC](https://forum.freecodecamp.org/t/intermediate-algorithm-scripting-wherefore-art-thou/604022/4 "2023-10-12T05:54:56Z")

</div>

Closed on October 12, 2023, 5:54am UTC

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