📅  最后修改于: 2022-03-11 15:03:31.647000             🧑  作者: Mango
let counter = str => {
return str.split('').reduce((total, letter) => {
total[letter] ? total[letter]++ : total[letter] = 1;
return total;
}, {});
};
counter("aabsssd"); // => { a: 2, b: 1, s: 3, d: 1 }