title: JavaScript: How to filter array by values nested in object 2 level deep
body: <p>I have an array of objects.</p>
  <p>Within each object of the array, there can be multiple &quot;Book&quot; objects, all with dynamic keys. I want the objects with at least one &quot;Book&quot; object that is new.</p>
  <p>For example:</p>
  <pre><code>const arr = [
    {
      id: '123',
      book1242: {isNew: true},
      book9023: {isNew: false},
    },
    {
      id: '123',
      book0374: {isNew: false},
      book9423: {isNew: false},
    },
    {
      id: '123',
      book8423: {isNew: false},
      book9023: {isNew: false},
    },
    {
      id: '123',
      book6534: {isNew: true},
      book9313: {isNew: false},
    },
  ]
  </code></pre>
  <p>So my filtered array will consist of the first and last element of the original array</p>
  <p>Expected filtered array</p>
  <pre><code>const arr = [
    {
      id: '123',
      book1242: {isNew: true},
      book9023: {isNew: false},
    },
    {
      id: '123',
      book6534: {isNew: true},
      book9313: {isNew: false},
    },
  ]
  </code></pre>
  <p>I have tried using <code>filter</code> and <code>map</code>, but I get to the point where I have to loop through and check which book is new and I'm not sure how to return that object within the filter.</p>