refactor: extract shuffleArray to lib/utils, rename correctAnswers to terms

This commit is contained in:
lila 2026-04-28 13:17:24 +02:00
parent c46729f365
commit 2ff7d1759e
5 changed files with 59 additions and 60 deletions

10
apps/api/src/lib/utils.ts Normal file
View file

@ -0,0 +1,10 @@
export const shuffleArray = <T>(array: T[]): T[] => {
const result = [...array];
for (let i = result.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
const temp = result[i]!;
result[i] = result[j]!;
result[j] = temp;
}
return result;
};