Simple snippet to shuffle array
If you need to shuffle the elements of an array, you can use this simple function:
function shuffle(array) {
const copy = [...array]
return copy.sort(() => Math.random() - 0.5)
}
The algorithm
Creates a copy of the parameter to not modify the ...
blog.gabrielrufino.com1 min read