I don't know why, but this code is not assigning cha[cha.indexOf(x[x.length-1]) + 1]'s value to x[x.length - 1]. I tried to convert it to any array but that didn't do anything.
var cha = "abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "0123456789";
var n = notch; // number to start counting from
var x = cha[0];
// stuff
console.log(x);
// generation loop
while (n > 0) {
if(x[x.length - 1] == cha[cha.length-1]) {
// ^ correct logic
x[length] = cha[0];
} else {
//
newPush = cha[cha.indexOf(x[x.length-1]) + 1];
a = x /*.split("");
a.pop(); <= Failed attempt
a.push(newPush);*/
x = a;
//x[x.length-1] = cha[cha.indexOf(x[x.length-1]) + 1];
//x[x.length-1] = "D";
console.log("x[x.length - 1] = " + x[x.length - 1]);
console.log("cha[cha.indexOf(x[x.length-1]) + 1] = " + cha[cha.indexOf(x[x.length-1]) + 1]);
}
n--;
console.log(cha[cha.indexOf(x[x.length-1]) + 1]);
console.log(x.lastIndexOf(x[x.length-1]) + 1);
console.log("n = " + n + ", x = " + x);
}
I want the new character from cha[cha.indexOf(x[x.length-1]) + 1] assigned to x[x.length - 1]. I've been debugging it in the Chrome developer tools (v23.0.1271.64), but I highly doubt it is specific to Chrome. I probably don't understand the value/reference passing or something, but any help is appreciated. (Please include a code sample if you can.)