Skip to content

Instantly share code, notes, and snippets.

Created December 1, 2015 03:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/cb5a39899c6e2d9a34e5 to your computer and use it in GitHub Desktop.
Save anonymous/cb5a39899c6e2d9a34e5 to your computer and use it in GitHub Desktop.
http://www.freecodecamp.com/dbess1 's solution for Bonfire: Title Case a Sentence
// Bonfire: Title Case a Sentence
// Author: @dbess1
// Challenge: http://www.freecodecamp.com/challenges/bonfire-title-case-a-sentence
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function titleCase(str) {
return str.toLowerCase().replace(/^[a-z]|\s[a-z]/g, function(i){ return i.toUpperCase(); } );
}
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