Hi,
i have to create a unique random number between 'min' and 'max' as a filename. My problem is a fast way for making sure that the generated number is already not used. Think i have to use a list (called in the not working example 'usedNums') to save the generated numbers and to test.
Can you help me? Sorry, for that, i'm an absolute newby
function random() {
var num = return Math.floor(Math.random() * (max - min + 1)) + min;
while (usedNums.includes(num)) {
num = return Math.floor(Math.random() * (max - min + 1)) + min;
}
usedNums.Add(num);
return num;
}
Random number
Re: Random number
Code: Select all
objct = {}; while(objct.__count__ < nmbr = 10)
v = ~~(Math.random() * nmbr) + 1, objct[v] = v;
(arr = objct.reflect.properties).splice(nmbr, 4), arr