Javascript examples for Math:random
Generate random number between 2 variables
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){// w w w . j a v a 2s. com var minNumber = -100; var maxNumber = 40 var randomNumber = randomNumberFromRange(minNumber, maxNumber); function randomNumberFromRange(min,max) { return Math.floor(Math.random()*(max-min+1)+min); } console.log(randomNumber); } </script> </head> <body> </body> </html>