Sample code for 30+ languages & platforms
JavaScript

Generating Random Integer in Range

See more PRNG Examples

Demonstrates how to generate random integers in a specified range.
Note
This example is intended for running within a Chilkat.Js embedded JavaScript engine. All Chilkat JavaScript examples require Chilkat v11.4.0 or greater.
JavaScript
var success = false;

// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

success = false;

var fortuna = new CkPrng();

// Generate random integers between 12 and 24 inclusive
var i;
for (i = 0; i <= 100; i++) {
    console.log(fortuna.RandomInt(12,24));
}