title: Changing string characters in an array - Javascript
body: <p>I am working through some problems on CoderByte. The goal of this function is to take a string and capitalize the first letter of each word. For example, <code>'hello world'</code> to <code>'Hello World'</code>. I can't figure out why this code gives me <code>'hello world'</code> and not <code>'Hello World'</code>. I know this line <code>array[i][0] = array[i][0].toUpperCase();</code> is the problem, but don't understand why it isn't working. I came up with an alternative solution but I am wondering why this didn't work. Thanks so much for your help! </p>
  
  <pre><code>function LetterCapitalize(str) { 
      var array = str.split(' ');
      for (var i = 0; i &lt; array.length; i++) {
          array[i][0] = array[i][0].toUpperCase();
      }
  return array.join('');
  } 
  
  LetterCapitalize('hello world');
  </code></pre>