We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
var func = function(str) { // 统计每个字母出现的次数 var obj = {}; for (let i = 0; i < str.length; i++) { if (!obj[str.charAt(i)]) { obj[str.charAt(i)] = 1 } else { obj[str.charAt(i)] ++; } // obj 对象的key值是字符名,value是出现次数 // 找出value最大的key并输出就可以了 var max = 0, thisChar; for (keyValue in obj) { if (obj[keyValue] > max) { max = obj[keyValue] thisChar= keyValue } } return thisChar; } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
思路
实现
The text was updated successfully, but these errors were encountered: