Calculating the number of times a string with each character appearing Array.reduce es6 () method

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 }

Guess you like

Origin www.cnblogs.com/calvin-dong/p/11223167.html