Last active
June 6, 2017 19:26
-
-
Save kfarst/00ec62364948338d7a9201710e8c5113 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 jadenCase (input) { | |
// Split the input into an array of individual words | |
var words = input.split(' '); | |
for (var i = 0; i < words.length; i++) { | |
// For each word take the first letter, captialize it, take the rest of the word, lowercase it, | |
// then re-assign the modified word to the current position in the array | |
words[i] = words[i].charAt(0).toUpperCase() + words[i].substr(1).toLowerCase(); | |
} | |
// Join the array of words back together into a string separated by spaces | |
return words.join(' '); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment