Created
November 3, 2016 02:01
-
-
Save basekays/a85636535186c39f4be405d204447067 to your computer and use it in GitHub Desktop.
take a string, change the first character of each word into capitalized letter :)
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) { | |
| var strLowerCase = str.toLowerCase(); | |
| var split = strLowerCase.split(" "); | |
| for (var i = 0; i< split.length; i++) { | |
| var firstChar = split[i].charAt(0).toUpperCase(); | |
| split[i] = firstChar + split[i].substr(1); | |
| } | |
| var newStr = split.join(" "); | |
| return newStr; | |
| } | |
| titleCase("fOrce aWAKENS"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment