function shuf(arr){
for(var i=arr.length-1;i>=1;i--){
var temp=arr[i];
var ran=Math.floor(Math.random()*i);
arr[i]=arr[ran];
arr[ran]=temp;
return(arr);
}
}
function build() {
var arr=[1,2,3,4];
var arrB=[];
for(var i=0;i<3;i++){
arr=shuf(arr);
arrB.push(arr);
}
return arrB;
}
this dosent do what I thought it would.
I thought it would give me an array of shuffled versions of arr.
like
[
[1,2,3,4,5],
[2,1,3,5,4],
[3,5,4,1,2]
]
but it gives me
[
[2,3,1,4,5],
[2,3,1,4,5],
[2,3,1,4,5]
]
it shuffles the first time, but not the rest…
I have no idea why that would be unless for some reason it will only run the shuf() function once inside a loop?