Workshop › Breakout › Step 32 of 39
The player wins when no brick is left standing. every asks exactly that. Then the big message says You win!.
```js
if (bricks.every((b) => !b.alive)) state = 'won'
if (state === 'won' || state === 'lost') {
ctx.font = 'bold 36px sans-serif'
ctx.fillText(state === 'won' ? 'You win!' : 'Game Over', canvas.width / 2, 250)
```every is true only if the arrow function is true for every brick: all of them dead.a ? b : c is a short "if": 'You win!' when the state is 'won', otherwise 'Game Over'.update, write the every line at the end of the if (brick) block, under else ball.vx = -ball.vx.draw, change the lost block's first line and its fillText line as shown.Skills: Game states, Arrays and objects
← Show the score One function for a new game →