Skip to content

Instantly share code, notes, and snippets.

Created December 7, 2015 09:59
Show Gist options
  • Save anonymous/0a0aec132ba4d030c68a to your computer and use it in GitHub Desktop.
Save anonymous/0a0aec132ba4d030c68a to your computer and use it in GitHub Desktop.
http://www.freecodecamp.com/patrickcurl 's solution for Bonfire: Title Case a Sentence
// Bonfire: Title Case a Sentence
// Author: @patrickcurl
// Challenge: http://www.freecodecamp.com/challenges/bonfire-title-case-a-sentence#
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function titleCase(str) {
words = str.split(" ");
for(var i=0;i<words.length;i++){
words[i] = words[i].charAt(0).toUpperCase() + words[i].substr(1).toLowerCase();
}
return words.join(" ");
}
titleCase("I'm a little tea pot");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment