Random Number Generator in JS

Do you want to learn how to generate random numbers in JS ?? Here is the video tutorial for you.

Download | Demo


Source Code:

<!DOCTYPE html>
		<title>Random Number Generator</title>
		<script type="text/javascript">

		function generateRandomNumber(){
			var min = parseInt(document.getElementById('min').value);
			var max = parseInt(document.getElementById('max').value);
			var rand = Math.floor(Math.random() * (max - min + 1)) + min;
			document.getElementById('display').innerText = rand;

		<input id="min" type="text" /><br />
		<input id="max" type="text" /><br />
		<button onclick="generateRandomNumber();">Generate</button>
		<div id="display" style="font-size:60px;"></div>


Leave a Reply

Your email address will not be published. Required fields are marked *