尝试调用newGame函数时收到错误

时间:2020-09-03 16:34:04

标签: javascript function

我正在尝试设置一个事件监听器,一旦游戏初始化它就会“监听”。但是当我加载页面时,出现以下错误:

hangman.js:10 Uncaught TypeError: newGame is not a function
    at init (hangman.js:10)
    at hangman.js:191

这是相关代码:

var init = function (){
  var timer;
  input = prompt('Please enter a guessable word:  ')
  welcome.textContent = 'Player 1 has entered a word. Player two may begin guessing';
  word.textContent = input;
  setTimeout(invisibleOpener, 13000);
  newGame()

}


var newGame = function(){
  startGame.addEventListener('click', function(){
    console.log('test');
  })
}

0 个答案:

没有答案