|
Last change
on this file since ba17441 was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
1.4 KB
|
| Line | |
|---|
| 1 | /**
|
|---|
| 2 | * Generate a random number within the given range.
|
|---|
| 3 | *
|
|---|
| 4 | * If only one argument is provided, a number between `0` and the given number is returned.
|
|---|
| 5 | *
|
|---|
| 6 | * @param {number} maximum - The upper bound (exclusive).
|
|---|
| 7 | * @returns {number} A random number between 0 (inclusive) and maximum (exclusive). The number can be an integer or a decimal.
|
|---|
| 8 | * @throws {Error} Throws an error if `maximum` is not greater than `0`.
|
|---|
| 9 | *
|
|---|
| 10 | * @example
|
|---|
| 11 | * const result1 = random(5); // Returns a random number between 0 and 5.
|
|---|
| 12 | * const result2 = random(0); // If the `maximum` is less than or equal to 0, an error is thrown.
|
|---|
| 13 | */
|
|---|
| 14 | declare function random(maximum: number): number;
|
|---|
| 15 | /**
|
|---|
| 16 | * Generate a random number within the given range.
|
|---|
| 17 | *
|
|---|
| 18 | * @param {number} minimum - The lower bound (inclusive).
|
|---|
| 19 | * @param {number} maximum - The upper bound (exclusive).
|
|---|
| 20 | * @returns {number} A random number between minimum (inclusive) and maximum (exclusive). The number can be an integer or a decimal.
|
|---|
| 21 | * @throws {Error} Throws an error if `maximum` is not greater than `minimum`.
|
|---|
| 22 | *
|
|---|
| 23 | * @example
|
|---|
| 24 | * const result1 = random(0, 5); // Returns a random number between 0 and 5.
|
|---|
| 25 | * const result2 = random(5, 0); // If the minimum is greater than the maximum, an error is thrown.
|
|---|
| 26 | * const result3 = random(5, 5); // If the minimum is equal to the maximum, an error is thrown.
|
|---|
| 27 | */
|
|---|
| 28 | declare function random(minimum: number, maximum: number): number;
|
|---|
| 29 |
|
|---|
| 30 | export { random };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.