()
| 1 | // See 12r.js for the full code. |
| 2 | function autoPlay() { |
| 3 | if (!isAutoPlaying) { |
| 4 | intervalId = setInterval(() => { |
| 5 | const playerMove = pickComputerMove(); |
| 6 | playGame(playerMove); |
| 7 | }, 1000); |
| 8 | isAutoPlaying = true; |
| 9 | |
| 10 | // When the game is auto playing, change |
| 11 | // the text in the button to 'Stop Playing'. |
| 12 | document.querySelector('.js-auto-play-button') |
| 13 | .innerHTML = 'Stop Playing'; |
| 14 | |
| 15 | } else { |
| 16 | clearInterval(intervalId); |
| 17 | isAutoPlaying = false; |
| 18 | |
| 19 | // When the game is not playing, change |
| 20 | // the text back to 'Auto Play'. |
| 21 | document.querySelector('.js-auto-play-button') |
| 22 | .innerHTML = 'Auto Play'; |
| 23 | } |
| 24 | } |
nothing calls this directly
no test coverage detected