Added samples
This commit is contained in:
@ -3,5 +3,6 @@
|
||||
Use `sort()` to reorder elements, utilizing `Math.random()` to randomize the sorting.
|
||||
|
||||
```js
|
||||
const randomizeOrder = arr => arr.sort( (a,b) => Math.random() >= 0.5 ? -1 : 1)
|
||||
const randomizeOrder = arr => arr.sort( (a,b) => Math.random() >= 0.5 ? -1 : 1);
|
||||
// randomizeOrder([1,2,3]) -> [1,3,2]
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user