mirror of
https://github.com/musix-org/musix-oss
synced 2025-06-17 13:56:01 +00:00
Init
This commit is contained in:
11
src/struct/funcs/shuffle.js
Normal file
11
src/struct/funcs/shuffle.js
Normal file
@ -0,0 +1,11 @@
|
||||
module.exports = function (a) {
|
||||
for (let i = a.length - 1; i > 1; i--) {
|
||||
const j = Math.floor(Math.random() * (i + 1));
|
||||
if (i === 0 || j === 0) {
|
||||
console.log(`J or I is 0. I: ${i} J: ${j}`);
|
||||
} else {
|
||||
[a[i], a[j]] = [a[j], a[i]];
|
||||
}
|
||||
}
|
||||
return a;
|
||||
};
|
Reference in New Issue
Block a user