Try it yourself.
Javascript math floor math random.
When you add the min at the end you are adding the 2 to your range and end up with a random number from 2 to 10.
The floor method rounds a number downwards to the nearest integer and returns the result.
In a nutshell one calls math floor when you want to truncate a decimal value to its nearest integer by just dropping the decimal portion.
Math floor math random max min 1 is generating a whole number between the range of 0 to 8.
Math random used with math floor can be used to return random integers.
If the passed argument is an integer the value will not be rounded.
The max min 1 is the logic that creates the range.
Return a random number between 1 and 10.
So 3 9 becomes 3 2 1 becomes 2 etc.
Yes the results will be evenly distributed.
The math random function returns a floating point pseudo random number in the range 0 to less than 1 inclusive of 0 but not 1 with approximately uniform distribution over that range which you can then scale to your desired range.
Math random will always generate a number that is strictly less than 1 i e 0 x 1 so math floor math random 255 will generate a random number between 0 and 254.
Math floor null returns 0 not a nan.
Description because floor is a static method of math you always use it as math floor rather than as a method of a math object you created math is not a constructor.