title: upperCase the first element of a string in JavaScript
body: <p>The error shows &quot;<em>AssertionError: expected '   NEVER GIVE UP' to deeply equal ' NEVER  GIVE UP '</em>&quot;
  and I can't figure out why blank in the beginning of a string is ignored. Here is my code:</p>
  <pre><code>function letterCapitalize(str) {
    if (str === '') {
      return ''
    }
    let string = '' //array to string
    let word = str.split(' ')
    for (let i = 0; i &lt; word.length; i++) {
      if (word[i] !== '') {
        string = string + word[i][0].toUpperCase() + word[i].slice(1, word[i].length) + ' '
      } else if (word[i] === '') {
        string = ' ' + string
      }
    }
    return string.slice(0, string.length - 1)
  }
  </code></pre>
  <p>The console log examples include:</p>
  <pre><code>let output1 = letterCapitalize('hello world');
  console.log(output1); // &quot;Hello World&quot;
  let output2 = letterCapitalize('javascript  is sexy ');
  console.log(output2); // &quot;Javascript  Is Sexy &quot;
  </code></pre>