Skip to content

Instantly share code, notes, and snippets.

@irrationalistic
Created July 1, 2014 20:01
Show Gist options
  • Save irrationalistic/cb19eea1859c9079c12b to your computer and use it in GitHub Desktop.
Save irrationalistic/cb19eea1859c9079c12b to your computer and use it in GitHub Desktop.
Get the word with the highest character repetition
var getReps = function(str){
return _.chain(str.split(' '))
.map(function(w){
return {
word: w,
reps: _.chain(w.toUpperCase().split(''))
.groupBy(_.identity)
.max(function(g){
return g.length;
})
.value()
.length;
};
})
.max(function(w){
return w.reps;
})
.value()
.word;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment