I’m a beginner with only 2 months experience in front-end. I’m trying to make a simple web-grid game.
I’ve got a 10×10 grid table (grid container with 100 div child elements in it), and my goal is that, when the site is opened, a random grid item out of the 100 gets automatically selected, and when the user clicks on that randomly selected grid item, another grid item out of the 100 gets randomly selected automatically, and the previously selected item gets de-selected (color goes back to the default state for example).
I was thinking I could do something with Math.random
, but I don’t know how. Any help or suggestions is appreciated!
HTML code is just
<div class="grid-container"></div>
<div class="grid-item"></div>
<div class="grid-item"></div>
<!-- ... a hundred of these child elements for 10x10. -->
</div>
JavaScript is blank