Workshop › Simon Says Colors › Step 16 of 27
Now the player repeats the sequence. inputAt counts how far they have got, and every press is checked against that
one step: a wrong pad ends the game ('over'), a right one moves on, and after the last step the next round starts.
```js
let inputAt // how many pads of the sequence the player has repeated
inputAt = 0
function press(pad) {
if (state !== 'input') return
if (pad !== sequence[inputAt]) {
state = 'over'
return
}
inputAt += 1
if (inputAt === sequence.length) nextRound()
}
```sequence[inputAt] is the pad expected now. A different pad ends the game.inputAt; when it equals the length, the whole sequence was repeated: nextRound() adds a pad
and starts a new show (and sets inputAt back to 0).let state to include 'over', and under let timer write let inputAt.nextRound, write inputAt = 0.light, leave an empty line and write press.Skills: Game states, Functions
← Watch, then your turn Play with the keyboard →