Update index.ts

This commit is contained in:
Andros Fenollosa 2022-02-19 17:37:55 +01:00 committed by GitHub
parent 40f92d6e84
commit 2011a2940d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -144,14 +144,14 @@ export function cloneJSON(json: JSON): JSON {
* @return {number} * @return {number}
* @example * @example
* *
* getRandom(0, 4) * random(0, 4)
* // => 3 (Maybe) * // => 3 (Maybe)
* *
* getRandom(0, 10, 2) * random(0, 10, 2)
* // => 8.31 (Maybe) * // => 8.31 (Maybe)
* *
*/ */
export function getRandom(min: number, max: number, decimals: number=0): number { export function random(min: number, max: number, decimals: number=0): number {
const minRandom = Math.ceil(min); const minRandom = Math.ceil(min);
const maxRandom = Math.floor(max); const maxRandom = Math.floor(max);
return (Math.random() * (maxRandom - minRandom + 1) + minRandom).toFixed(decimals); return (Math.random() * (maxRandom - minRandom + 1) + minRandom).toFixed(decimals);