feat: [frontend] Add randomItemInArray helper

This commit is contained in:
wilson 2026-05-04 07:59:59 +01:00
parent e075f2dc39
commit 4c60a3ca91
2 changed files with 5 additions and 0 deletions

View file

@ -1,2 +1,3 @@
// place files you want to import through the `$lib` alias in this folder. // place files you want to import through the `$lib` alias in this folder.
export { shuffleArray } from './shuffleArray'; export { shuffleArray } from './shuffleArray';
export { randomItemInArray } from './randomItemInArray';

View file

@ -0,0 +1,4 @@
export function randomItemInArray<T>(arr: Array<T>): T {
const index = Math.floor(Math.random() * arr.length);
return arr[index];
}