function gapLot(){
var array6=[];
var array2=[1,2,3,4,5,6];
var random;
for(var i=0;i<6;i++){ //0-5
random= Math.floor(Math.random() * (6-i))+1;
if(random==(6-i)){
array6[i]=array2[5-i];
}else{
array6[i]=array2[random-1];
array2[random-1]=array2[5-i];
}
}
return array6;
}
console.log(gapLot());
Wednesday, January 18, 2023
Problem: Fill array by dice numbers; all different 2
Subscribe to:
Post Comments (Atom)
3D blog is ending
Later this month, 3D-blog will end. Thanks for all.
-
Javascript random is nice, because it is between 0 and 1; So you can like: Math.random()*sum where you get then numbers between 0 and the...
-
You got array of 6, It need to be fill dice-numbers all less that 6 more than one. We talk about 1,2,3,4,5,6. Minimal O is preferred. I...
No comments:
Post a Comment