Как передать результат из метода playerElementChoice () в startGame ()
class Game {
constructor() {
this.options = document.querySelectorAll('.options');
this.options.forEach(item => {
item.addEventListener('click', this.playerElementChoice);
});
document.querySelector('button.start').addEventListener('click', this.startGame.bind(this));
}
playerElementChoice() {
const name = this.firstElementChild.className;
return name;
}
startGame() {
console.log(this.playerElementChoice());
}
}
При попытке вызвать метод playerElementChoice () в методе startGame () я получаю сообщение об ошибке:
Не удается прочитать свойство 'className' из неопределенного в Game.playerElementChoice (Game.js: 17) в Game.startGame (Game.js: 28).
Что я делаю не так?