ght-calcnum
v1.0.1
Published
这是用来统计字符串中每个字符出现的个数
Downloads
7
Readme
说明
这是用来统计字符串每个字符出现个数的工具
下载说明
npm install ght-calcnum
使用方法
var fun=required('ght-CalcNum');
console.log(fun('abcdaba'));
详情代码
function calc(str){
let obj={}
for(let i=0;i<str.length;i++){
let num=0;
for(let j=0;j<str.length;j++){
if(str.charAt(i)==str.charAt(j)){
num++;
}
}
obj[str.charAt(i)]=num;
}
return obj;
}