Each time you will get a different value by using this button
We will use Math.floor to get random number within a range.
Random number Between 1 and 10Output can be equal to 1 but always less than 10 ( not equal to 10 ) , Random integer is also displayed by using Math.floor()
Random number between 90 & 100 ( both inclusive )
Generate Random integer between two values ( both inclusive)
By using FunctionThe return value from this function is random number between 0 and 1. As we have to remove the decimal part to get random numbers between 0 to 10.
We will multiply the random number returned by math.random() by 11 and then take the floor value of it to get the random number. We have used floor value as this function returns the lower integer part only. If we use round function then the value will be adjusted to nearest integer so floor function gives more accurate random number.
Here is the demo of random number generator.Here is the total code of this demo.
You can read the php random number generator and
ASP random number generator
This article is written by plus2net.com team.