title: calculate the count of object using reduce or filter in javascript
body: <p>I've written a method to calculate the number of objects in an array which have 'enabled' set to 'true'.</p>
  
  <p>I'm adding 1 to counter each time it finds an object in my array which has 'enabled' set to 'true'.</p>
  
  <p>How could I achieve this without using 'counter' variable and using reduce or filter instead??</p>
  
  <p>Here's my code:</p>
  
  <pre><code>function getCount() {               
      const arr =[[{ "enabled": true }], [{ "enabled": false}, {"enabled": true}]];                       
      var count = 0;
      arr.forEach(function(ar){
          ar.forEach(function(obj){
              if(obj.enabled) {
                  count++;
              }
          })
      });
      return count;           
  }
  </code></pre>