prefixed Array. to reduce(), sort(), map() methods in snippets.
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
### Randomize order of array
|
||||
|
||||
Use `sort()` to reorder elements, utilizing `Math.random()` to randomize the sorting.
|
||||
Use `Array.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);
|
||||
|
||||
Reference in New Issue
Block a user