Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 138249

Generating random integer JavaScript

$
0
0

I want to generate a random integer. When I enter a number in a textbox and call the function by clicking on a button, it says "The number was undefined", instead of giving the value of the generated number. Here is my code:

function getRandomInt(min, max){
    return Math.floor(Math.random(max-min+1)+min);
}

var array=[];
var integer=getRandomInt(1,100);
var broj=array[integer];

Viewing all articles
Browse latest Browse all 138249

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>