en.javascript.info/1-js/4-data-structures/2-number/8-random-min-max/task.md
2016-03-06 00:59:16 +03:00

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.