Workshop › Minesweeper › Step 19 of 26
The top left shows MINES - flags: how many mines are left if every flag is right. It is not stored anywhere; it is
counted from the grid each time it is drawn, so it can never be out of date.
```js
const flags = grid.flat().filter((cell) => cell.flagged).length
ctx.fillStyle = 'white'
ctx.font = 'bold 18px monospace'
ctx.textAlign = 'left'
ctx.fillText('💣 ' + (MINES - flags), 10, TOP / 2)
```flags counts the flagged cells.In draw, under the cell loop, leave an empty line and write the five lines. Press Run.
Skills: Game states, Drawing on a canvas