Files
outline/shared/random.ts
Apoorv Mishra 0a6cfe5a6a feat: Choose random color on collection creation (#3912)
Choose a random color from a shared color palette between backend
and frontend during collection creation.
2022-08-04 01:48:19 -07:00

10 lines
255 B
TypeScript

const randomInteger = (min: number, max: number) => {
return Math.floor(Math.random() * (max - min + 1) + min);
};
const randomElement = <T>(arr: T[]): T => {
return arr[randomInteger(0, arr.length - 1)];
};
export { randomInteger, randomElement };