Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JavaScript Generate a Random Number Between Two Numbers</title> </head> <body> <script> /* Defining a custom function which returns a random number between min and max, including min and max */ function generateRandomNumber(min, max) { return Math.floor(Math.random() * (max - min + 1) + min); } // Generate a random number between 1 and 10 (including 1 and 10) var randomNum = generateRandomNumber(1, 10); document.write(randomNum); </script> </body> </html>