# Generate random numbers between two numbers in JavaScript

Advertisements

We can use Math.random() method to generate random numbers between two numbers.

function getRandom(min, max) { min = Math.ceil(min); max = Math.floor(max); return Math.floor(Math.random() * (max - min)) + min; }

Advertisements