This report includes the Problem Statement, Algorithm Analysis, the Corrected Code Solution, and a detailed Code Breakdown to ensure the "fixed" requirements are met (specifically addressing the common issue where the code runs infinitely or crashes due to missing decrement logic).
The expression (row + col) % 2:
This creates the alternating pattern automatically. 916 checkerboard v1 codehs fixed
Not alternating correctly
Use (row + col) % 2 === 0 to determine color.
Square size / positioning wrong
If canvas is 400×400, each square = 50×50. This report includes the Problem Statement , Algorithm
Off-by-one in loops
Ensure you loop rows 0–7 and columns 0–7.
| Mistake | Why It Happens | Fix |
|---------|----------------|------|
| Colors are offset (e.g., top-left black) | Used (row + col) % 2 === 1 for red | Use === 0 for red |
| Board starts red but columns don't alternate | Forgot to add row and col together | Use (row + col) % 2 |
| Squares overlap or wrong spacing | Used same x/y for all squares | Multiply by squareSize |
| Board is only 4x4 or wrong size | Wrong number of rows/cols | Set numRows = 8, numCols = 8 | Why This Works
The expression (row + col) % 2 :
The 916 Checkerboard problem on CodeHS is a classic challenge that requires creating a checkerboard pattern using a loop. Here is a fixed and well-documented solution: