Workshop › Sudoku › Step 16 of 28

The solved message

What we are doing

When the puzzle is solved, a dark band across the middle three rows shows the time it took.

```js
if (won) {
  ctx.fillStyle = 'rgba(15, 23, 42, 0.75)'
  ctx.fillRect(0, TOP + 3 * SIZE, canvas.width, 3 * SIZE)
  ctx.fillStyle = 'white'
  ctx.font = 'bold 28px sans-serif'
  ctx.textAlign = 'center'
  ctx.fillText('Solved in ' + clock(seconds) + '!', canvas.width / 2, TOP + 4.5 * SIZE)
  ctx.font = '18px sans-serif'
  ctx.fillText('Click for a new puzzle', canvas.width / 2, TOP + 5.3 * SIZE)
}
```

What it means

Your turn

At the end of draw, under the time line, write the if (won) block.

Skills: Drawing on a canvas

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