Javascript : random number between variables issue
- by Mayhem
I've seen the other examples on this site but I just can't get it to work.
I'm trying to generate a random number between 2 user input variables on a form. The numbers will always be positive numbers.
min = document.getElementById('min').value;
max = document.getElementById('max').value;
waitTimer = Math.floor(Math.random() * (max - min + 1)) + min;
When min = 5 / max = 10, waitTimer is sometimes returning results like 2, 4 and 28 and so on.
What am I doing wrong?