Files
CCNA_Learning/src/rand.ts
2019-09-11 18:36:31 +02:00

9 lines
276 B
TypeScript

export default function randomize<T>(input: T[]): T[] {
let res: T[] = [];
input = [...input];
while (input.length > 0) {
let randomIndex = Math.floor(Math.random() * input.length);
res.push(...input.splice(randomIndex, 1));
}
return res;
}