I've looked all over for how to capitalize the first character of every word of a string, but nothing helped me. I need to set an entered string to a heading capital character lower case one . I've tried this:
function titleCase(str) {
//converting the giving string into array
str =str.split(" ");
//iterating over all elem.s in the array
for(var i=0;i<str.length;i++){
//converting each elem. into string
str[i]=str[i].toString();
//converting the first char to upper case &concatenating to the rest chars
str[i]=str[i].toUpperCase(str[i].charAt(0))+ str[i].substring(1);
}
return str;
}
titleCase("I'm a little tea pot");