Skip to content

Instantly share code, notes, and snippets.

@svahora
Last active August 29, 2015 14:24
Show Gist options
  • Save svahora/5d2947f4f7f0841f7bc8 to your computer and use it in GitHub Desktop.
Save svahora/5d2947f4f7f0841f7bc8 to your computer and use it in GitHub Desktop.
function titleCase(str) {
str = str.toLowerCase().split(" ");
var word = [];
for(x=0; x<str.length; x++) {
var a = str[x].charAt(0).toUpperCase();
var b = str[x].substr(1);
word.push(a + b);
}
str = word.join(' ');
return str;
}
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