Stumped here. When I try calling this.makeBoard(); it gives my a type error. Any help would be appreciated. I did not include my other methods, they give the same errors however.
Error: TypeError: this.makeBoard is not a function at HTMLInputElement
class Game {
constructor() {
this.init();
}
init() {
this.board = [];
this.currPlayer = 1;
this.button = document.querySelector("#submit");
this.button.addEventListener('click', function(e){
e.preventDefault();
const htmlBoard = document.querySelector('#board');
this.width = parseInt(document.querySelector('#width'));
this.height = parseInt(document.querySelector('#height'));
while (htmlBoard.firstChild) {
htmlBoard.removeChild(htmlBoard.firstChild)
}
this.makeBoard();
});
}
makeBoard() {
for (let y = 0; y < this.height; y++) {
this.board.push(Array.from({ length: this.width }));
}
}
}
new Game();