# How to generate random numbers between two numbers in JavaScript?

JavascriptWeb DevelopmentFront End Technology

To generate random numbers between two numbers, use Math.random() method.

## Example

You can try to run the following code to get random numbers between a minimum and maximum number −

Live Demo

<!DOCTYPE html>
<html>
<body>
<script>
function randomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min)) + min;
}
</script>
</body>
</html>
Published on 03-Feb-2018 16:40:23