title: find array in nested array of objects
body: <p>I want to find an array inside a nested array of objects, how can I do that?</p>
  <p>Here is my array</p>
  <pre><code>const arr = [
      {
          &quot;teamA&quot;: [
              {
                  &quot;_id&quot;: &quot;5fcb57c5a1a426c03bcfd25f&quot;,
                  &quot;level&quot;: 10,
                  &quot;username&quot;: &quot;asaf&quot;
              }
          ],
          &quot;teamB&quot;: [],
          &quot;options&quot;: {}
      },
      {
          &quot;teamA&quot;: [
              {
                  &quot;_id&quot;: &quot;a7fgy3h1uio&quot;,
                  &quot;level&quot;: 10,
                  &quot;username&quot;: &quot;asaf&quot;
              }
          ],
          &quot;teamB&quot;: [
              {
                  &quot;_id&quot;: &quot;13rfedsc32&quot;,
                  &quot;level&quot;: 10,
                  &quot;username&quot;: &quot;asaf&quot;
              },
              {
                  &quot;_id&quot;: &quot;dghg453r3q&quot;,
                  &quot;level&quot;: 10,
                  &quot;username&quot;: &quot;asaf&quot;
              }
          ],
          &quot;options&quot;: {}
      }
  ];
  </code></pre>
  <p>now I want to create a function that returns me the array of the team that a player is in by the _id</p>
  <p>for example, I created this:</p>
  <pre><code>const findTeam = playerId =&gt; {
      const match = arr.find(({ teamA, teamB }) =&gt; [teamA, teamB].some(team =&gt; team.some(i =&gt; i._id == playerId)));
      if(!match) return;
  
      const { teamA, teamB } = match;
      const team = [teamA, teamB].find(team =&gt; team.some(i =&gt; i._id == playerId));
      return team;
  };
  </code></pre>
  <p>and it's working, but the way I did it looks very messy, there is any neat way to do that?
  Thanks!</p>