Three Ways to Title Case a Sentence in JavaScript
Sonya Moisset

My solution seems to be unique:

function titleCase(str) {
 // make the whole string lower case and turn the string into and array
 str = str.toLowerCase().split(“”);
 str[0] = str[0].toUpperCase(); // make the first character upper case
 // iterate through the rest of the array and make every character upper case that follows a “ “
 for (var i = 1; i < str.length; i++) {
 if (str[i-1] === “ “) {
 str[i] = str[i].toUpperCase(); 
 str = str.join(“”);
 return str;

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.