516 B
516 B
importance: 2
A random number from min to max
The built-in function Math.random()
creates a random value from 0
to 1
(not including 1
).
Write the function random(min, max)
to generate a random floating-point number from min
to max
(not including max
).
Examples of its work:
alert( random(1, 5) ); // 1.2345623452
alert( random(1, 5) ); // 3.7894332423
alert( random(1, 5) ); // 4.3435234525
You can use the solution of the previous task as the base.