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 strToArray = str.split(" ");
var newArray = [];
for(var i=0; i < strToArray.length; i++){
var element = strToArray[i].replace(strToArray[i][0], strToArray[i][0].toUpperCase());
newArray.push(element);
}
return (newArray.join(" "));
}