Workshop › Tower Defense › Step 10 of 42
An enemy past the end of the road has got through: pointAt gives null. We mark it with hp = 0 (no health left)
and keep only the enemies with health. The same filter will later remove the ones the towers kill.
```js
for (const e of enemies) {
if (pointAt(e.d) === null) {
e.hp = 0
}
}
enemies = enemies.filter((e) => e.hp > 0)
```pointAt(e.d) === null means the enemy is past the end.filter builds a new list with the enemies whose hp is above 0.In update, under the walking line, write the loop and the filter.
Skills: Game states, Arrays and objects