Workshop › Typing Rain › Step 16 of 33
So far nothing bad happens when a word lands. Now each landed word costs a life. Two words could land in the same
frame, so we take away landed.length, not 1.
```js
const GROUND = 330 // a word that falls past this line costs a life
let lives
lives = 3
const landed = words.filter((w) => w.y > GROUND)
if (landed.length === 0) return
words = words.filter((w) => w.y <= GROUND)
if (landed.includes(target)) target = null
lives -= landed.length
```lives starts at 3.update stops right there; the rest only runs when something landed.lives -= landed.length takes one life for each landed word.GROUND.let typed ... write let lives; in reset, under typed = 0, write lives = 3.update, add the landed.length line under landed, and lives -= ... at the end.Skills: Game states
← Let go of a lost word Hearts →