title: Filtering nested objects via Attribute with Javascript-
body: <p>I have an array of nested objects, I want to filter this to return only the object tjat contains an author who's age === 21.</p>
  <p>I've attempted to implement this <a href="https://stackoverflow.com/questions/38375646/filtering-array-of-objects-with-arrays-based-on-nested-value">SO answer</a>, but I keep having 'x is not a function' returned.</p>
  <pre><code>let arrayOfElements = 
  [
    {
    author: { name: 'Kim', age: 21 },
    employment: { employer: 'Logiothech', role: 'Human Resources' }
    }
    
    {
    author: { name: 'John', age: 62 },
    employment: { employer: 'Logiothech', role: 'Human Resources' }
    }
    
    {
    author: { name: 'Mary', age: 31 },
    employment: { employer: 'Logiothech', role: 'Human Resources' }
    }
    
  ];
  </code></pre>
  <p>What I have tried: (I believe I'm incorrectly using subElements, but unsure what to correctly sub in it's place)</p>
  <pre><code> let filteredMap =  array_of_elements.map((element) =&gt; {
  return {...element, subElements: element.subElements.filter((subElement) =&gt; subElement.author.age === 21)}
  })
  </code></pre>