Generating random integer in range that doesn't start at zero
function getRandom(min, max) {
return min + Math.floor(Math.random() * (max - min + 1));
}
for(var x = 0; x < 5; x++) {
alert(getRandom(7, 10));
}
Math.floor(7 + Math.random() * 4)
will generate numbers from 7 to 10 inclusive.
Just say this:
Math.floor(Math.random()*4) + 7
This will generate a random number from 0-3 and then add 7 to it, to get 7-10.