Workshop › Sudoku › Step 7 of 28
Sudoku's three rules are about the row, the column and the box. We light up all three around the selected cell in grey, which makes the puzzle much easier to read.
```js
// Light up the selected cell's row, column and box, and every cell with the same digit.
const sameBox = Math.floor(r / 3) === Math.floor(selected.r / 3) && Math.floor(c / 3) === Math.floor(selected.c / 3)
let fill = '#ffffff'
if (r === selected.r || c === selected.c || sameBox) fill = '#e2e8f0'
```Math.floor(r / 3) is which band of boxes a row is in (0, 1 or 2); two cells are in the same box when both their row
band and column band match.fill, so the selected cell stays blue.In draw, write the comment and sameBox above let fill, and the grey rule under it.
Skills: Game states
← The selected cell The same digit everywhere →