i want to replace every Characters with number from 0 to 5
to make var string = "abcdef"; turn into "01245"
i tried this code but result was not what i want
var text = "abcdef";
var num =0;
var tx;
var res;
for (var char in text) {
tx = text[char];
res= text.replace(tx,num);
num = num+1;
console.log(res);
}