UNPKG

rambdax

Version:

Extended version of Rambda - a lightweight, faster alternative to Ramda

14 lines (12 loc) 309 B
export function shuffle(arrayRaw){ const array = arrayRaw.concat() let counter = array.length while (counter > 0){ const index = Math.floor(Math.random() * counter) counter-- const temp = array[ counter ] array[ counter ] = array[ index ] array[ index ] = temp } return array }