Hi, I wrote this function for the Title Case a Sentence challenge, the code seems to work fine but it doesn’t pass the challenge:
function titleCase(str) {
var array = str.toLowerCase().split(" ");
str = "";
for (var i = 0; i < array.length; i++) {
str += array[i][0].toUpperCase();
for (var j = 1; j < array[i].length; j++)
str += array[i][j];
str += " ";
}
return str;
}
titleCase("sHoRt AnD sToUt");
What should I do?
Sorry for my bad english!