标签:max logs class var ica i++ turn else aaa
function findMaxDepulicateChar(str) { var obj = {}; for (let i = 0, len = str.length; i < len; i++) { if (!obj[str[i]]) { obj[str[i]] = 1; } else { obj[str[i]] += 1; } } var maxChar = ‘‘; var max = 0; for (var key in obj) { if (obj[key] > max) { max = obj[key]; maxChar = key; } } return (‘maxChar:‘ + maxChar + ‘ sum:‘ + max); } var str = ‘aaaaddddddddfddfdhjjjjjjgdsbsdheldhfld‘; console.log(findMaxDepulicateChar(str)); // maxChar:d sum:15
标签:max logs class var ica i++ turn else aaa
原文地址:http://www.cnblogs.com/ax-null/p/6920988.html