I am trying to make a javascript program that takes a string and capitalizes the first letter of every word and makes every other character lowercase.
function titleCase(str) {
  str = str.toLowerCase();
  var array = str.split(" ");
  for(var i =0; i< array.length ; i++){
    array[i][0] = array[i].charAt(0).toUpperCase();
  } 
  var finalString = array.join(" ")
  return finalString ; 
}
console.log(titleCase("I'm a little tea pot"));For some reason array[i].charAt(0).toUpperCase(); won't pass it's value to array[i][0]. This ends up making it return the string with just all lowercase letters instead of having the first letter of each word being capitalized. 
 
     
     
     
     
    