+ 5
Random Number Series in JS
I want to generate 0,to 11 numbers randomly.. for example: "0,4,2,1,7,9,11,3,6,8,5,10" not like this "0,1,6,6,5,3,2,2,11,8,9,13" How can i do it
7 ответов
+ 8
var numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
function shuffle(o) {
for(var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
return o;
};
var random = shuffle(numbers);
document.write(random);
// by mirage //for M.A.sunera Madanperuma
+ 8
Math.floor(Math.random()*11);
+ 7
if you want from 1 to 11
Math.floor(Math.random()*11 + 1)
+ 6
welcome also thank you for making my answer as best answer
+ 5
Thank you very much broo
+ 4
nope it repeats numbers
i want to randomize numbers between 0 and 11
not to get 0 to 11 numbers randomly