I\'m trying to proper case a string in javascript - so far I have this code:
This doesn\'t seem to capitalize the first letter, and I\'m also stuck on how to lowercase all the l
function titleCase(str) {
var titleStr = str.split(' ');
for (var i = 0; i < titleStr.length; i++) {
titleStr[i] = titleStr[i].charAt(0).toUpperCase() + titleStr[i].slice(1).toLowerCase();
}
return titleStr.join(' ');
}
titleCase("i'm a little tea pot")