Workshop › Typing Rain › Step 27 of 33
Typists measure themselves in words per minute (WPM). Words have different lengths, so every five letters count as one word. The time comes from the frames: at 60 frames a second, a minute is 3600 frames.
```js
let frames
frames = 0
if (state !== 'playing') return
frames += 1
// Words per minute counts five letters as one word, the usual way.
const wpm = () => (frames === 0 ? 0 : Math.round(letters / 5 / (frames / 3600)))
```frames counts the frames played; it stops with the game because it is under the guard.letters / 5 is the words typed, frames / 3600 the minutes played; words divided by minutes is WPM.let letters write let frames; in reset, above letters = 0, write frames = 0.update, under the guard line, write frames += 1.const accuracy write the comment and wpm.Skills: Game states, Functions
← Accuracy Your speed at the end →