There are a classic problem of string manipulation, a number of statistics for each string of characters that appears.
With the Array.reduce es6 () function with the "..." symbol may be more easily extended to deal with the problem.
result:
{ a: 5, b: 2, n: 5, c: 2 }