|
Last change
on this file since a762898 was a762898, checked in by istevanoska <ilinastevanoska@…>, 6 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
267 bytes
|
| Rev | Line | |
|---|
| [a762898] | 1 | function 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 |
|
|---|
| 10 | export { shuffle };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.