generate random numbers in js
Math.floor((Math.random() * 100) + 1);
//Generate random numbers between 1 and 100
//Math.random generates [0,1)
generate random numbers in js
Math.floor((Math.random() * 100) + 1);
//Generate random numbers between 1 and 100
//Math.random generates [0,1)
javascript generate random array
//This example is to generate an array with 40 random elements, with random values from 0 to 39
for (var a=[],i=0;i<40;++i) a[i]=i;
// http://stackoverflow.com/questions/962802#962890
function shuffle(array) {
var tmp, current, top = array.length;
if(top) while(--top) {
current = Math.floor(Math.random() * (top + 1));
tmp = array[current];
array[current] = array[top];
array[top] = tmp;
}
return array;
}
a = shuffle(a);
generate an array of random numbers javascript
let numbersArray = [] , max = 100;
for( var i=1; numbersArray.push(i++) < max;); // numbers = [1,2,3 ... 100]
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us