题解 | #获得积分最多的人(一)#

字符串字符统计

http://www.nowcoder.com/practice/777d0cd160de485cae0b1fd1dd973b44


function count(str) {
    const rs={};
    const arr=str.replace(/\s*/g,'').split('');
    arr.forEach(e=>{
        if(rs[e]){
            rs[e]+=1;
        }else{
            rs[e]=1;
        }
    });
    return rs;

}

全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务