Workshop › Sudoku › Step 4 of 28

The puzzle's own digits

What we are doing

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'
```

What it means

Your turn

  1. Under let grid, write let given; in reset, work out given.
  2. In draw, choose the color and the font from given.

Skills: Game states

All steps

  1. Nine by nine
  2. Lines and boxes
  3. A puzzle from a string
  4. The puzzle's own digits
  5. Keep drawing
  6. The selected cell
  7. Light up row, column and box
  8. The same digit everywhere
  9. Click to select
  10. Move with the arrows
  11. Write digits
  12. The three rules in one loop
  13. Show mistakes
  14. Solved!
  15. A clock
  16. The solved message
  17. Play again
  18. The easiest cell
  19. The solver
  20. Random order
  21. Invent a puzzle
  22. A new puzzle every game
  23. Hints
  24. Best time
  25. N for a new puzzle
  26. A number pad
  27. Tap the pad
  28. Build it yourself: undo