JavaScript:
function select (n, min, max) {
/* Return n unique numbers selected randomly from the contiguous range min..max inclusive (n <= max-min+1) */
/* const numArray = []; */
var temp;
for (var i = 1; i <= n; i++)
{ temp = getRndInteger (min, max);
/* if contains (numArray, temp) { i-- }
else { numArray.push (temp) } */
alert (temp)
}
/* return numArray */
return 0;
}
Hi,
The lines commented out in the above function were intended to accumulate the unique generated numbers in a list and return that list.
What is the correct way to do this?
Many thanks.