Title case a sentence

Title case a sentence
0

#1

Hi, I’ve been reading all your solutions, which is so helpful. I’m falling in love with map(). I like the way you guys put the toLowerCase() at the end for the substr. Seems more efficient. I’m going to file that away.
Here’s how I did it.

function titleCase(str) {
var s=str.toLowerCase().split(’ ').map(function (word){var w=word.charAt(0).toUpperCase() + word.substr(1);return w;});

return s.join(’ ');
}

titleCase(“I’m a little tea pot”);

Any feedback?
(I know I didn’t name my variable very descriptively. Perhaps you could read in userStr.)