Created
June 23, 2019 13:36
-
-
Save amerllica/de594d5489c52f225c12ab5032b4b0e1 to your computer and use it in GitHub Desktop.
Simple array shuffler (Using reduce function)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const shuffler = array => array.reduce((accumulator, currentValue) => { | |
const randomIndex = Math.ceil(Math.random() * 10); | |
accumulator.splice(randomIndex, 0 ,currentValue); | |
return accumulator; | |
}, []); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment