Okay, just learning JavaScript here, I know I should search for the answer, but I can't even figure out what I should search for, im completely lost as to why this is happening
// string or array
var strr=[1,5,3];
//changed array.
var cha=[];
var t=0;
/*push strr into the cha array
should look like
[
[1,5,3],
[1,5,3],
[1,5,3]
]
*/
for(var i=0;i<3;i++){
cha.push(strr);
}
//shuffle each element one by one
for(a in cha){
cha[a]=cha[a].sort(function()
{return Math.floor(Math.random()*100)-50;
});
}
//each element should be a re arranged array with the same elemnts of strr
// Like 135, 351, 153 for example
console.log(cha);
// But it arranges all of the elements the same. the shuffle changed the order of strr, but not each of cha...
// Like 351,351,351 for example, they are randomized, but all the same.