Filtering nested objects via Attribute with Javascript-

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.

I’ve attempted to implement this SO answer, but I keep having ‘x is not a function’ returned.

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' }
  }
  
];

What I have tried: (I believe I’m incorrectly using subElements, but unsure what to correctly sub in it’s place)

 let filteredMap =  array_of_elements.map((element) => {
return {...element, subElements: element.subElements.filter((subElement) => subElement.author.age === 21)}
})