diff --git a/packages/falso/src/lib/core/core.ts b/packages/falso/src/lib/core/core.ts index d03c3bdbd..b3d9a8ca3 100644 --- a/packages/falso/src/lib/core/core.ts +++ b/packages/falso/src/lib/core/core.ts @@ -74,7 +74,7 @@ export function fakeFromArray( const newArray: T[] = []; while (clonedData.length && newArray.length !== options.length) { - const randomIndex = getRandomInRange({ max: clonedData.length - 1 }); + const randomIndex = Math.floor(random() * clonedData.length); const item = clonedData[randomIndex]; newArray.push(item); @@ -85,8 +85,7 @@ export function fakeFromArray( } export function randElement(arr: T[]): T { - const randomIndex = getRandomInRange({ max: arr.length - 1 }); - return arr[randomIndex]; + return arr[Math.floor(random() * arr.length)]; } export interface RandomInRangeOptions {