Created
August 2, 2017 14:20
-
-
Save manfromanotherland/e16fef6cb0ebe6ed987aa2b0c636f57a to your computer and use it in GitHub Desktop.
JS: Convert string to Title case with JavaScript
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 titleCase(str) { | |
return str.toLowerCase().split(' ').map(function(word) { | |
return (word.charAt(0).toUpperCase() + word.slice(1)); | |
}).join(' '); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment