// ... in class ConnectFourView /** * Connects this view to the given game. * * @param {ConnectFourModel} game */ connectToGame(game) { let index = 0; for (let button of this.grid.getElementsByTagName("button")) { // Use a constant value that will be captured in the // event listener. Use modulo operator to compute the column // from the button index. const column = index % game.width; button.addEventListener("click", () => { game.insertPiece(column); this.fillHtml(game); }); index++; } } /** * Updates the view (button elements) to match the game state. * * @param {ConnectFourModel} game */ fillHtml(game) { // Modify the HTML DOM to match the game state, using the following properties: // element.setAttribute(, "value") // element.innerHTML = "content" // element.classList.add() }