Currently, I am working on a personal project that involves creating a grid of divs in HTML corresponding to a 2D array in JavaScript. However, I am uncertain about the most effective way to accomplish this task.
Specifically, what I aim to achieve is that when a div in the grid is clicked, it should change color and modify a number in the array from 0 to 1 (or vice versa). Although there are other numbers involved, this is the basic functionality.
I believe using an onClick listener to change the class of the div would be the optimal approach to handle the color change, but how can I establish a connection between the array and the grid?
Thank you in advance for any assistance you can provide.