Last active
September 26, 2019 11:42
-
-
Save mrroot5/6e02fed4cc2313ce127f887325b88f21 to your computer and use it in GitHub Desktop.
Javascript title case capitalize
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 titleCase(text) { | |
if (typeof text !== 'string') return '' | |
return text.charAt(0).toUpperCase() + text.slice(1).toLowerCase(); | |
} | |
var myString = "my awesomE String"; | |
titleCase(myString); | |
// My awesome string |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment