标签:turn ret return nbsp abc get var obj null
var str = ‘abcdadfggaaaageaaaaapoasa‘;
function getTotal(str) {
var obj = {};
for(var i=0; i<str.length; i++) {
var k = str.charAt(i);
if(obj[k]) {
obj[k]++;
} else {
obj[k] = 1;
}
}
var m =0;
var i =null;
for(var k in obj) {
if(obj[k] > m){
m = obj[k];
i = k;
}
}
return {maxNum: m, maxStr: i};
}
标签:turn ret return nbsp abc get var obj null
原文地址:http://www.cnblogs.com/aivnfjgj/p/6915599.html