[Home] >  Random >  Generate a random integer in given range

Generate a random integer in given range

JavaScript version

const randomInteger = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min;

TypeScript version

const randomInteger = (min: number, max: number): number => Math.floor(Math.random() * (max - min + 1)) + min;