Last active
March 29, 2019 12:00
-
-
Save seunzone/ca27dc13921316d6584ee9968b004cfb to your computer and use it in GitHub Desktop.
This file contains 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
const maxChar = str => { | |
const myStr = str.toLowerCase(); | |
const charMap = {}; | |
let max = 0; | |
let maxChar = ''; | |
for (let char of myStr) { | |
if (!charMap[char]) { | |
charMap[char] = 1; | |
} else { | |
charMap[char]++; | |
} | |
} | |
for (let char in charMap) { | |
if (charMap[char] > max) { | |
max = charMap[char]; | |
maxChar = char; | |
} | |
} | |
return maxChar; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment