@techmely/utils
Version:
Collection of helpful JavaScript / TypeScript utils
18 lines (14 loc) • 364 B
JavaScript
/*!
* @techmely/utils
* Copyright(c) 2021-2024 Techmely <techmely.creation@gmail.com>
* MIT Licensed
*/
// src/shuffleArray.ts
function shuffle(array) {
for (let i = array.length - 1; i > 0; i--) {
const factor = Math.floor(Math.random() * (i + 1));
[array[i], array[factor]] = [array[factor], array[i]];
}
return array;
}
export { shuffle };