How to start a function ONLY on a button click

I am looking to have my grid style game start once I click the start button on my page. Currently the game starts as soon as I click the grid, but I want this function to be invoked only when the you click the Start Button.

I already created my game Board. Which can be called using this function: createBoard(). Styling for this board is full of my divs and working.

I tried the solutions previously given in my other thread and still had an issue with the function not invoking only at the click of a start button.

Here is my replit: Any feedback on what I’m doing wrong? Thanks! :slight_smile:

https://replit.com/@batb/WholeFrostyLocus :slight_smile:

Be sure you have a listener registered to your start button and give it a handler that then sets up the listeners on the board (and turns off the Start Button listener, or hides the button). If you use delegation and all your grid elements are in a parent, then register the listener on the parent and use event.target to find the clicked element. When the game ends, turn off that listener, and turn on the Start Button listener.