I have a small string and a fixed seed and I am trying to shuffle all the string elements with the given seed so its repeatable.
Here is the code I have:
function shufff(strin,seed){
var tem;
var j;
var tt = strin.length;
for(var i=0; i<tt; i++){
j = ( seed % (i+1) + i) % tt;
tem=strin[i];
strin[i] = strin[j];
strin[j] = tem;
}
return strin;
}
var tom='tomollow';
alert(shufff(tom,6543));
This returns the original string back with no shuffling.
What am I doing wrong?