I basically want to capitalize the first letter in every word in a sentence, assuming that str is all lowercase. So here, I tried to split the string, letter by letter, then by using for loop, I would capitalize whatever the letter that's after a space. Here's my code and could you please point out where I coded wrong? Thank you.
function titleCase(str) {
  var strArray = str.split('');
  strArray[0].toUpperCase();
  for (i=0; i<strArray.length;i++){
    if (strArray[i]===" "){
      strArray[i+1].toUpperCase();
    }
  }
  return strArray.join('');
}
 
     
     
    