计数器统计字符串中字符出现次数
//'abcdefabcadefkmmkggcc'
var str5 = 'abcdefabcadefkmmkggcc'
var obj = {
}
for (i = 0; i < str5.length; i++) {
var key=str5[i]
if (obj[key]) {
obj[key]++
} else {
obj[key] = 1
}
}
for(var key in obj){
console.log(key,obj[key]);
}