Random # between?

im trying to generate a random # from 10 and whatever the user enters but there seems to be a problem, is this right?

Math.floor(Math.random() * input.value) + 10;

If the input value is 40 you will need to do random numbers up to 30, then add 10 to that.

So random from 0 to 10 less than the input value, then add 10 to that.

1 Like

ok, is this what you mean

Math.floor(Math.random() * (input.value - 10)) + 10;

Yes indeed.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.