title: javascript find child object in nested arrays
body: <p>I have a javascript structure like below (nested arrays of objects)</p>
  
  <pre><code>var categoryGroups = [
      {
          Id: 1, Categories: [
              { Id: 1 },
              { Id: 2 }, 
          ]
  
      },
      {
          Id: 2, Categories: [
              { Id: 100 },
              { Id: 200 },
          ]
  
      }
  ]
  </code></pre>
  
  <p>I want to find a child Category object matching an Id, assuming the Category Id's are all unique.</p>
  
  <p>I've got this below, but was wondering if there is a more concise way of doing it:</p>
  
  <pre><code>var category, categoryGroup, found = false;
  for (i = 0; i &lt; categoryGroups.length ; i++) {
      categoryGroup = categoryGroups[i];
      for (j = 0; j &lt; categoryGroup.Categories.length; j++) {
          category = categoryGroup.Categories[j];
          if (category.Id === id) {
              found = true;
              break;
          }
      }
      if (found) break;
  }
  </code></pre>