Skip to content

Instantly share code, notes, and snippets.

@piqueen314 piqueen314/gist4
Created Dec 11, 2015

What would you like to do?
Return the provided string with the first letter of each word capitalized. Make sure the rest of the word is in lower case.
// Bonfire: Title Case a Sentence
// Author: @piqueen314
// Challenge:
// Learn to Code at Free Code Camp (
function titleCase(str) {
var words=str.split(" ");
for(var i=0; i<words.length; i++)
words[i]=words[i].charAt(0).toUpperCase()+ words[i].slice(1);
str= words.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
You can’t perform that action at this time.