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; } alert(randomInt(5,25)); </script> </body> </html>