title: How to count a number of specific elements in an object?
body: <p>I have a set of items <code>fruitItems</code> which looks like this:</p>
  
  <pre><code>[
      {
          "name": "banana",
          "origID": "7064012136"
      },
      {
          "name": "apple",
          "origID": "8390108418"
      },
      {
          "name": "pineapple",
          "origID": "8317598430"
      },
      {
          "name": "banana",
          "origID": "8395091043"
      },
      {
          "name": "orange",
          "origID": "8391923474"
      }
  ]
  </code></pre>
  
  <p>How do I get the number of <code>banana</code> in this list?
  I tried doing this:</p>
  
  <pre><code>fruitItems.name.filter(x =&gt; x === "banana").length;
  </code></pre>
  
  <p>But it throws <code>ReferenceError: fruitItems is not defined</code> even though it is defined.</p>