Skip to content

Instantly share code, notes, and snippets.

@crimx
Created December 3, 2015 09:05
Show Gist options
  • Save crimx/5ac48e7cfa81cd054015 to your computer and use it in GitHub Desktop.
Save crimx/5ac48e7cfa81cd054015 to your computer and use it in GitHub Desktop.

Revisions

  1. crimx created this gist Dec 3, 2015.
    13 changes: 13 additions & 0 deletions count-letters.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    function count(s) {
    var r = s.split('')
    .sort()
    .join('')
    .match(/(\w)\1*/g)
    .sort(function(a,b) {
    return a.length < b.length
    });
    return {
    letter: r[0],
    count: r.length
    }
    }