I want to select a random number out of a set. For example from the set {8, 6, 1, 7}.
You can use following function to get a random number out of a set:
function getRndmFromSet(set)
{
var rndm = Math.floor(Math.random() * set.length);
return set[rndm];
}
in your case the call would be getRndmFromSet([8,6,1,7])
Try the jsFiddle
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments