Last active
December 16, 2015 20:50
-
-
Save lionelB/5495734 to your computer and use it in GitHub Desktop.
capitalize it !
http://jsperf.com/str-capitalize
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 capitalize(str) { | |
return str.replace(/^[a-zàáâãäåçèéêëìíîïðòóôõöùúûüýÿñ]/, function(x) { | |
return String.fromCharCode(x.charCodeAt(0) - 32); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment