source: node_modules/es-toolkit/dist/array/shuffle.mjs

Last change on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 267 bytes
Line 
1function shuffle(arr) {
2 const result = arr.slice();
3 for (let i = result.length - 1; i >= 1; i--) {
4 const j = Math.floor(Math.random() * (i + 1));
5 [result[i], result[j]] = [result[j], result[i]];
6 }
7 return result;
8}
9
10export { shuffle };
Note: See TracBrowser for help on using the repository browser.