function countMaxRepeat ( options ) { let set = {} for( let i = 0; i < options.length; i++ ) { if ( !set[ options[i] ] ) set[ options[i] ] = 0 set[ options[i] ] += 1 } let arr = [] Object.keys( set ).forEach( key => { arr[ set[ key ] ] = !arr[ set[ key ] ] ? key : arr[ set[ key ] ] + ',' + key }) return { tag: arr[ arr.length - 1 ], count: arr.length - 1 } } // 多个字母同次 用,拼接返回 console.log( JSON.stringify(countMaxRepeat('aaaccccdddd')) )