I have my replaceAt method look like something from here
String.prototype.replaceAt = function(index, c) {
return this.substr(0, index) + c + this.substr(index+c.length);
}
I have a trim at function which removes whitespace starting at a specific index from a string that looks like this:
String.prototype.startTrimAt = function(i) {
var string = this;
while (string.charAt(i) == ' '){
string = string.replaceAt(i, '');
}
return string;
};
So this function would work like this:
"( tree)".startTrimAt(1); //returns (tree)
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