Generates a random floating-point number within a specified range.
The returned value is greater than or equal to min and less than max.
min
max
The lower bound of the range (inclusive).
The upper bound of the range (exclusive).
A random floating-point number between min (inclusive) and max (exclusive).
// Generate a random float between 0 and 1const result1 = randomFloat(0, 1);// Generate a random float between 10 and 20const result2 = randomFloat(10, 20);// Generate a random float between -5 and 5const result3 = randomFloat(-5, 5); Copy
// Generate a random float between 0 and 1const result1 = randomFloat(0, 1);// Generate a random float between 10 and 20const result2 = randomFloat(10, 20);// Generate a random float between -5 and 5const result3 = randomFloat(-5, 5);
Generates a random floating-point number within a specified range.
The returned value is greater than or equal to
min
and less thanmax
.