I have an array of PAIRS of 25 images (meaning a total of 50 images) each image path being in its own associative array.
const cardArray = [
{ name:'A', img:'images/A.jpg' },
{ name:'A', img:'images/A.jpg' },
{ name:'B', img:'images/B.jpg' },
{ name:'B', img:'images/B.jpg' },
{ name:'C', img:'images/C.jpg' },
{ name:'C', img:'images/C.jpg' },
...
... (bla bla bla, up to 25 times)
]
I know that if I have exactly 8 pairs then the function I can use is:
cardArray.sort(() => 0.5 - Math.random())
What I'd like to do is to randomly select 8 pairs of these images, then shuffle them like in a memory match game. How do I make it so that every time the user reloads the browser, different pairs of images from the array will load instead of the same 8 ones every time?
Thanks.