const findMaxStr = (str)=>{
let arr = str.split('');
let count = {};
let maxCount = 0;
let mostChar;
for(let i = 0;i<arr.length;i++){
let char = arr [i]
if(count[char]!==undefined){
count[char]++
}else{
count[char] = 1
}
}
Object.keys(count).forEach(char=>{
if(count[char]>maxCount){
maxCount = count[char]
mostChar = char
}
});
return '出现频率最高的字符是:' + mostChar + ',出现次数为:' + maxCount
}
console.log(findMaxStr('hello world'))