编辑代码

let testStr = "aaabbbbbccddddddddddx"
function getCharCode(str) {
    let obj = {}
   for(let char of str){
        obj[char] = !obj[char] ? 1 : Number(obj[char]) + 1
   }
    let max = Math.max(...Object.values(obj));
    let maxObj = Object.entries(obj).find(x => x[1] == max)
    return maxObj
}
console.log(getCharCode(testStr))