title: Filter inside filter in JavaScript
body: <p>I need to filter some data inside an array of objects which is contained in another array of objects. Here is the sample structure of my data. I need to filter on <code>categories</code>.</p>
  <pre><code>[
      {
      id: 540,
      name:'Makeup kit'
      slug:'makeup-kit',
      status:'publish',
      categories: [
              {
                  id: 42, name:'Fashion',slug:'fashion'
              },
              {
                  id: 43, name:'Beauty',slug:'beauty'
              }
          ]
      },
      {
      id: 541,
      name:'Silicon gloves'
      slug:'silicon-gloves',
      status:'publish',
      categories: [
              {
                  id: 44, name:'Health',slug:'health'
              }
          ]
      },
      {
      id: 650,
      name:'Julep Mask'
      slug:'julep-mask',
      status:'publish',
      categories: [
              {
                  id: 43, name:'Beauty',slug:'beauty'
              }
          ]
      }
  ]
  </code></pre>
  <p>Here is how I'm trying</p>
  <pre><code>beautyProducts=temp1.filter(product=&gt;product.categories.filter(cat=&gt;cat.id===43))
  </code></pre>
  <p>but my solution doesn't seem to work.</p>