Files
30-seconds-of-code/snippets/randomize-order-of-array.md
Angelos Chalaris 0893f79360 Fibonacci and random
2017-11-30 19:45:56 +02:00

8 lines
205 B
Markdown

### Randomize order of array
Use `sort()` to reorder elements, utilizing `Math.random()` to randomize the sorting.
```js
var randomizeOrder = arr => arr.sort( (a,b) => Math.random() >= 0.5 ? -1 : 1)
```