Random Number Generator Get a specified amount of random numbers within a range of 0 to n, using raw JavaScript--jquery or any other JavaScript framework was not used. To use, simply import the randomNumberGenerator script in your
tag: And call the randomNumberGenerator() function somewhere, supplying the amount of numbers you want back (aka, the length of the returned array), and the highest number in the range, i.e,: randomNumberGenerator(3, 28); ...attached to a button, will return an array of random numbers each time it is clicked: [0,7,4] [15,17,3] [1,4,26] This is useful for gaming scripts that require 1 or more random numbers for AI and the like, especially when a random positions in an array/arrays are required. I currently use a form of this function in the States Game and Workout Randomizer. Some improvement ideas: [ ] Ability to pass in arrays, array lengths, string lengths, etc., rather than just numbers [ ] Option to have an object returned, with key/value pairs, for some flexibility [ ] Code optimization