W
e
l
c
o
m
e
: )

统计一个字符串中每个字符出现的次数

function count(str) {
  return [...str].reduce((res,i)=>{
      res[i]?res[i]++:res[i]=1
      return res
  },{})
}

posted @ 2020-07-03 09:28  口木秋子  阅读(376)  评论(0编辑  收藏  举报