Workshop › Sudoku › Step 4 of 28
The digits the puzzle starts with are fixed. A second grid, given, remembers them: dark and bold. Digits you write
later will be blue and thin.
```js
let given // given[r][c]: true for the puzzle's own digits, which cannot be changed
given = grid.map((row) => row.map((d) => d !== 0))
ctx.fillStyle = given[r][c] ? '#0f172a' : '#2563eb'
ctx.font = (given[r][c] ? 'bold ' : '') + '26px sans-serif'
```grid.map((row) => row.map(...)) makes a grid of the same shape: true where the puzzle has a digit.condition ? a : b.let grid, write let given; in reset, work out given.draw, choose the color and the font from given.Skills: Game states
← A puzzle from a string Keep drawing →