Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

generate diffrent random array Numbers

const usedIndexes = new Set();    
function getUniqueRandomNumber(max, min = 0) {
  const newNumber = Math.floor(Math.random() * (max - min) + min);
  if (usedIndexes.has(newNumber)) {
    return this.getUniqueRandomNumber(max, min);
  } else { 
    usedIndexes.add(newNumber);
    return newNumber;
  }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #generate #diffrent #random #array #Numbers
ADD COMMENT
Topic
Name
9+2 =