loading...

Discussion on: Basic JavaScript AI Algorithm

Collapse
dallgoot profile image
dallgoot

that's where theory specialists meet coding specialists :

var newString = '';
    for (i = 0; i < this.code.length; i++) {
        if (i == index) newString += newChar;
        else newString += this.code[i];
    }

    this.code = newString;

equals

newString = this.code.substr(0,index) + newChar + this.code.substr(index+1);
Collapse
createdd profile image