Created
February 12, 2018 18:01
-
-
Save dragonza/54c15af0c997ad38224504147af9b5a7 to your computer and use it in GitHub Desktop.
Find commonly used character
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function maxChar(str) { | |
const obj = {}; | |
str.split('').forEach(char => obj[char] + 1 || 1); | |
return Object.keys(obj).reduce((prev, next) => obj[a] >= obj[b] ? a : b); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment