refactor(api, curriculum): use the shared shuffleArray util (#56444)

Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
This commit is contained in:
Huyen Nguyen
2024-10-02 06:55:38 -07:00
committed by GitHub
parent 52ea949997
commit 0ba9eeff43
4 changed files with 8 additions and 42 deletions
+4 -1
View File
@@ -4,7 +4,10 @@ export const shuffleArray = <T>(arrToShuffle: Array<T>) => {
for (let i = arr.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[arr[i], arr[j]] = [arr[j], arr[i]];
// We know that i and j are within the bounds of the array, TS doesn't
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
[arr[i], arr[j]] = [arr[j]!, arr[i]!];
}
return arr;