(e)
| 61 | } |
| 62 | |
| 63 | function hit(e){ |
| 64 | let start = e.target.start; |
| 65 | let end = new Date().getTime(); |
| 66 | let duration = (end-start)/1000; |
| 67 | let maxDuration = 1; |
| 68 | |
| 69 | clearTimeout(playArea.timer); |
| 70 | showMessage('It took you ' + duration + ' seconds to click'); |
| 71 | if (duration > maxDuration){ |
| 72 | gameArea.children[0].remove(); |
| 73 | results.innerHTML = `Too Slow! <span id="loser">You Lose!</span> Your score was ${count}.<br> Click the start button to play again!`; |
| 74 | resetGame(); |
| 75 | } else { |
| 76 | gameArea.children[0].remove(); |
| 77 | playArea.timer = setTimeout(myBox, random(4000)); |
| 78 | count++; |
| 79 | if (count === 15){ |
| 80 | results.innerHTML = `You reached ${renderCount(count)}! <span id="winner">You win!</span> <br> Click start to Play again.`; |
| 81 | resetGame(); |
| 82 | } else { |
| 83 | results.innerHTML = `Score: ${renderCount(count)} of 15`; |
| 84 | } |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | function renderCount(count){ |
| 89 | return count; |
nothing calls this directly
no test coverage detected