Created
January 3, 2019 15:30
-
-
Save mhartington/b0c7379867822477be1aa7350c773d81 to your computer and use it in GitHub Desktop.
This file contains 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 toTitleCase(str) { | |
return str.replace( | |
/\w\S*/g, | |
txt => txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase() | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment