I've got two arrays
const mp3 = ['sing.mp3','song.mp3','tune.mp3','jam.mp3',etc];
const ogg = ['sing.ogg','song.ogg','tune.ogg','jam.ogg',etc];
I need to shuffle both arrays so that they come out the same way, ex:
const mp3 = ['tune.mp3','song.mp3','jam.mp3','sing.mp3',etc];
const ogg = ['tune.ogg','song.ogg','jam.ogg','sing.ogg',etc];
There's a few posts on stackoverflow that shuffle arrays in the way I described --this one is pretty great-- but none of them demonstrate how to shuffle two arrays using Lodash.
The JavaScript methods library is known as weak, it has the sort()
method but it doesn't have the shuffle()
method, thus, all the answers are mixing the logic of shuffling an array & And & keeping the shuffle identical among multiple arrays. Therefore I thought that creating a separate question here would be a great idea.
and for the shuffeling part of the algorithm, I chose Lodash, since I'm using it, and it's the most popular JavaScript utilities library out there.
thnx!