Problem
Build an N x N grid of cells that responds interactively — e.g., hovering a cell highlights its diagonals (or selecting cells highlights along the diagonal of the clicked cell).
Requirements
- Render an N x N grid (N configurable).
- On hover/click of a cell
(r, c), highlight all cells on the same diagonals: wherer - c === R - C(main) andr + c === R + C(anti-diagonal). - Clear highlight on mouse leave (for hover variant).
Hints / Approach
- Store cells as a flat array of
{ row, col }or compute from index:row = Math.floor(i / N),col = i % N. - A cell is on the active diagonal if
row - col === activeRow - activeColorrow + col === activeRow + activeCol. - Keep only the active cell in state; derive highlight per render to avoid storing O(N^2) flags.