cards/utils.ts
2026-01-16 21:14:50 -07:00

12 lines
359 B
TypeScript

export const arrayOfLength = (length: number): number[] => {
return [...Array(length).keys()]
}
export function arrayShuffle(array: any[]) {
const copy = [...array]; // Create a shallow copy
for (let i = copy.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[copy[i], copy[j]] = [copy[j], copy[i]];
}
return copy;
}