I've been working on developing a memory game using JavaScript, and I've encountered some challenges along the way. After successfully designing the HTML and CSS components, my focus has now shifted to implementing the JavaScript functionality. One key aspect of the game involves assigning randomly generated images to pairs of cards from an array containing image sources. However, I've noticed that when I execute the shuffleImages()
function, the resulting image pairs are not always consistent, with some appearing in odd numbers rather than even pairs as required for the game.
This issue leads me to the following question: How can I ensure that the images assigned are always in even pairs? It's important to note that I am relatively new to JavaScript and have only been coding for about two weeks.
Any guidance or suggestions would be greatly appreciated.
Here is the HTML/CSS/JavaScript code snippet: