summaryrefslogtreecommitdiff
path: root/src/lib/utils.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/utils.ts')
-rw-r--r--src/lib/utils.ts5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/lib/utils.ts b/src/lib/utils.ts
index 0674dea..0f0c084 100644
--- a/src/lib/utils.ts
+++ b/src/lib/utils.ts
@@ -63,3 +63,8 @@ export function cleanIpa(ipa: string): string {
const r2 = /[\[\]\/]/g;
return ipa.replace(r1, "").replace(r2, "");
}
+
+export function randomFromArray<T>(arr: T[]): T {
+ const idx = Math.floor(Math.random() * arr.length);
+ return arr[idx]!;
+}