9.1.6 Checkerboard V1 Codehs !free! Jun 2026

Defining NUM_ROWS and NUM_COLS at the top of your script is a programming best practice. If you later want to change your checkerboard into a

You need to create a grid where cells alternate colors (usually black and white) to resemble a checkerboard. In CodeHS, this typically involves using the Grid class and the Color constants. The Logic: The "Odd/Even" Rule

Completing "Checkerboard, v1" teaches you several key concepts: 9.1.6 checkerboard v1 codehs

// Constants for the grid setup var NUM_ROWS = 8; var NUM_COLS = 8; // Colors used for the checkerboard var COLOR_ONE = Color.black; var COLOR_TWO = Color.red; function start() // Calculate size dynamically based on canvas width var squareSize = getWidth() / NUM_COLS; // Outer loop iterates through each row for (var r = 0; r < NUM_ROWS; r++) // Inner loop iterates through each column in that row for (var c = 0; c < NUM_COLS; c++) // Calculate coordinates for the current square var xPos = c * squareSize; var yPos = r * squareSize; // Create the square graphic object var square = new Rectangle(squareSize, squareSize); square.setPosition(xPos, yPos); // Determine color based on row + column parity if ((r + c) % 2 === 0) square.setColor(COLOR_ONE); else square.setColor(COLOR_TWO); // Add the completed square to the canvas add(square); Use code with caution. Code Breakdown and Explanations The Setup and Constants

grid of alternating colored squares (typically black and red, or black and white) that fills the canvas canvas perfectly. Key Technical Constraints : 8 rows and 8 columns (64 total squares). Defining NUM_ROWS and NUM_COLS at the top of

Here is the complete JavaScript solution using the CodeHS graphics library. javascript

The vertical position depends on the current row index r . This shifts the drawing pen downward every time the outer loop advances. The Logic: The "Odd/Even" Rule Completing "Checkerboard, v1"

board, you only need to change these two variables rather than hunting through your loops. The Nested Loop Architecture

The "9.1.6 Checkerboard, v1" exercise, found in CodeHS courses like "Georgia Foundations of Artificial Intelligence" and "WCSD Python II", is the first step in a three-part project. The ultimate goal is to build a program that stores numbers representing checkers pieces on a board. In this initial version, you are tasked with creating the basic board structure in the form of a .

By checking if (row + col) % 2 === 0 , the program builds a flawless, self-correcting diagonal pattern across the entire canvas without needing manual, hardcoded overrides for every line. Common Errors and Debugging Tips

Get GIS jobs by Email

Subscribe to our Email Alert and receive notice anytime new jobs are posted!

You can cancel email alerts at any time.

THANK YOU!

Mail Icon Email Subscription Activated
You have successfully subscribed to our job alert email.
Close