title: Using javascript/lodash to group identical values for a specific key and count them and return results to an array
body: <p>I have a collection of objects from which I use lodash's _.map function to get all the corresponding values for a specific key:</p>
  
  <pre><code>[{
      "id": 1,
      "alarm_type": "danger",
      "data": "Dapibus ac facilisis in facilisilitumas el perfertum"
  }, {
      "id": 2,
      "alarm_type": "danger",
      "data": "Cras sit amet nibh libero"
  }, {
      "id": 3,
      "alarm_type": "warning",
      "data": "Porta ac consectetur ac"
  }, {
      "id": 4,
      "alarm_type": "info",
      "data": "Vestibulum at eros porta ac consectetur ac"
  }, {
      "id": 5,
      "alarm_type": "success",
      "data": "Morbi leo risus"
  }, {
      "id": 6,
      "alarm_type": "default",
      "data": "Lorem ipsum dolor sit amet, consectetur adipiscing elit."
  }, {
      "id": 7,
      "alarm_type": "danger",
      "data": "Cras sit amet nibh libero"
  }, {
  }, {
      "id": 8,
      "alarm_type": "default",
      "data": "Dolor sit amet, consectetur adipiscing."
  }, {
      "id": 9,
      "alarm_type": "default",
      "data": "Dolor sit amet, consectetur adipiscing elit."
  }]
  </code></pre>
  
  <p>The javascript functions:</p>
  
  <pre><code>var alarmsQueue = alarms.getAlarms();
  
  alarmsQueue.then(function(result) {
  
      var alarmsTypes = _.map(result, 'alarm_type');
  
      console.log(alarmsTypes);
  
  });
  </code></pre>
  
  <p>The result is the following array:</p>
  
  <pre><code>["danger", "danger", "warning", "info", "success", "default", "danger", "default", "default"]
  </code></pre>
  
  <p>And I would like to obtain the following object from the previous:</p>
  
  <pre><code>{"danger": 3, "warning": 1, "info": 1, "success": 1, "default": 3}
  </code></pre>
  
  <p>What would be the best way to proceed?</p>