Aggregate summary counts for an array of error objects
Here’s another one towards functional using es6 syntax additions:

const predSeverity = severity =&gt; err =&gt; err.severity == severity
const byCode = (acc, {errorCode: code}) =&gt;
  acc.set(code, (acc.get(code) || 0) + 1)

errorLog.filter(predSeverity("H")).reduce(byCode, new Map())


It has a bit different result data format (and type, if only for the receiver-as-return-value of Map::set), since the filtering already tells us the severity.