MCPcopy Create free account
hub / github.com/SuperSimpleDev/javascript-course / autoPlay

Function autoPlay

1-exercise-solutions/lesson-12/12r.js:25–45  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

23
24//};
25function autoPlay() {
26 if (!isAutoPlaying) {
27 intervalId = setInterval(() => {
28 const playerMove = pickComputerMove();
29 playGame(playerMove);
30 }, 1000);
31 isAutoPlaying = true;
32
33 // Solution for 12t.
34 document.querySelector('.js-auto-play-button')
35 .innerHTML = 'Stop Playing';
36
37 } else {
38 clearInterval(intervalId);
39 isAutoPlaying = false;
40
41 // Solution for 12t.
42 document.querySelector('.js-auto-play-button')
43 .innerHTML = 'Auto Play';
44 }
45}
46
47// Solution for exercise 12s.
48document.querySelector('.js-auto-play-button')

Callers 5

12r.jsFile · 0.70
12w.jsFile · 0.70
12x.jsFile · 0.70
12u.jsFile · 0.70
12s.jsFile · 0.70

Calls 4

pickComputerMoveFunction · 0.70
playGameFunction · 0.70
setIntervalFunction · 0.50
clearIntervalFunction · 0.50

Tested by

no test coverage detected