Skip to content

Instantly share code, notes, and snippets.

@dragonza
Created February 12, 2018 18:01
Show Gist options
  • Save dragonza/54c15af0c997ad38224504147af9b5a7 to your computer and use it in GitHub Desktop.
Save dragonza/54c15af0c997ad38224504147af9b5a7 to your computer and use it in GitHub Desktop.
Find commonly used character
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