title: javascript replace character at index problem
body: <p>I have my replaceAt method look like something from <a href="https://stackoverflow.com/questions/1431094/how-do-i-replace-a-character-at-a-particular-index-in-javascript">here</a></p>
  
  <pre><code>String.prototype.replaceAt = function(index, c) {
    return this.substr(0, index) + c + this.substr(index+c.length);
  }
  </code></pre>
  
  <p>I have a trim at function which removes whitespace starting at a specific index from a string that looks like this: </p>
  
  <pre><code>String.prototype.startTrimAt = function(i) {
      var string = this;
      while (string.charAt(i) == ' '){
          string = string.replaceAt(i, '');
      }
      return string;
  };
  </code></pre>
  
  <p>So this function would work like this:</p>
  
  <pre><code>"(  tree)".startTrimAt(1); //returns (tree)
  </code></pre>
  
  <p>The problem i am having is that it just loops in the startTrimAt function and I am not sure why. Any help would be appricated. Thanks</p>