Skip to content

Instantly share code, notes, and snippets.

@kfarst
Last active June 6, 2017 19:26
Show Gist options
  • Save kfarst/00ec62364948338d7a9201710e8c5113 to your computer and use it in GitHub Desktop.
Save kfarst/00ec62364948338d7a9201710e8c5113 to your computer and use it in GitHub Desktop.
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