Remove duplicate snippets. Simplify implementation

This commit is contained in:
Darren Scerri
2017-12-13 22:56:36 +01:00
parent f6426792d3
commit 1bd89ffe75
4 changed files with 13 additions and 39 deletions

View File

@ -0,0 +1,8 @@
### Shuffle array
Use `Array.sort()` to reorder elements, using `Math.random()` in the comparator.
```js
const shuffle = arr => arr.sort(() => Math.random() - 0.5);
// shuffle([1,2,3]) -> [2,3,1]
```