获取字符串中每个字母出现的次数

//获取字符串中每个字母出现的次数
var str='qwerewdddfugg’;
var b=str.split('’);
var c={};
for(var i=0;i<b.length;i++){
   if(c.hasOwnProperty(b[i])){
      c[b[i]]++
    }else{
     c[b[i]]=1
    }
};
console.log(c)

猜你喜欢

转载自blog.csdn.net/m0_37646522/article/details/79732007