Fibonacci and random
This commit is contained in:
7
snippets/randomize-order-of-array.md
Normal file
7
snippets/randomize-order-of-array.md
Normal file
@ -0,0 +1,7 @@
|
||||
### 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)
|
||||
```
|
||||
Reference in New Issue
Block a user