The most robust way to fix the alternating color bug without complex boolean flags is to use the .
The pieces appear crooked or do not tile correctly. 916 checkerboard v1 codehs fixed
: Using getWidth() / DIAMETER ensures that your checkerboard fills the screen regardless of how big the canvas is. Pro-Tip for CodeHS Debugging The most robust way to fix the alternating
coordinate depends on the row index. Reversing these results in a diagonal line or a broken vertical stack instead of a grid. 2. Static Color Switching Pro-Tip for CodeHS Debugging coordinate depends on the
function start() // Set up canvas var WIDTH = 400; var HEIGHT = 400; var ROWS = 8; var COLS = 8; var squareSize = WIDTH / ROWS; // Nested loops to create the board for(var row = 0; row < ROWS; row++) for(var col = 0; col < COLS; col++) var x = col * squareSize; var y = row * squareSize; var rect = new Rectangle(squareSize, squareSize); rect.setPosition(x, y);