How to do this ? (Q & A)
Generate given length of Array in Random Value
In any condition,
I want to generate an Array easily
var array1 = [1, 2, 3, 4, 5];
var array2 = new Array(10);
But,
I want to generate an Array length with 100 and given random value ?
Here’s the magic solution I found.
Array.apply(null, { length: 100 }).map(function () {
return Math.ceil(Math.random() * 100 + 1);
});Done