Workshop › Wordle-style Word Guess › Step 7 of 26
What the player types is a string that grows: current. type(key) adds a letter at the end, but only while there are
fewer than five. reset() prepares a new game.
```js
let current // the letters typed so far
function reset() {
current = ''
}
function type(key) {
if (current.length < 5) current += key
}
reset()
```current holds the letters typed so far; '' is an empty string.current.length is how many letters it has; += adds key at the end.reset() is called once at the start.const TOP = 12, leave an empty line and write let current, then reset and type.reset() above requestAnimationFrame(loop). Press Run.Skills: Game states, Functions
← Draw again and again Type with the keyboard →