计算字符串中出现次数最多的字符及个数
<script>
function infinity(str) {
var arr = str.split("")
.sort()
.join("")
.replace(/((.)\2*)/g, "$1,")
.split(",")
.sort(function(a, b) {
return b.length > a.length
});
return [arr[0][0], arr[0].length];
}
console.log(infinity("1222333999551111111"));
</script>