let str='asjfhsdgbmzxgaudsnfkjndgjkdsngnzbdsjkbgjkdsbg'; let wjy={},word; // let len=str.length; for(let i = 0;i<str.length;i++){ word=str[i]; if(wjy[word]){ wjy[word]++ }else{ wjy[word]=1; } } var maxNum = 0; let arr = []; for(key in wjy){ if(maxNum<wjy[key]){ maxNum = wjy[key]; } } for(key in wjy){ if(wjy[key] == maxNum){ arr.push(key) } } console.log(wjy) console.log("出现最多的字母是"+ arr,"出现的次数为" + maxNum + "次")