Skip to content

Latest commit

 

History

History
7 lines (5 loc) · 205 Bytes

randomize-order-of-array.md

File metadata and controls

7 lines (5 loc) · 205 Bytes

Randomize order of array

Use sort() to reorder elements, utilizing Math.random() to randomize the sorting.

var randomizeOrder = arr => arr.sort( (a,b) => Math.random() >= 0.5 ? -1 : 1)