function choice<T>(items: T[]): T {
if (items.length === 0) {
throw new Error('Cannot choose from empty list without fallback');
}
return items[Math.floor(Math.random() * items.length)]!;
}
Choice
Picking a random choice snippet.
Dec 1, 2022