9.1.7 Checkerboard V2 Codehs [verified] Official

Start by defining the size of the board and the squares. Using constants makes your code easy to modify later. javascript

for (let row = 0; row < 8; row++) for (let col = 0; col < 8; col++) // Draw a single square at (col, row)

Once you have the basic checkerboard working, here are some modifications to test your skills:

for (let row = 1; row <= 8; row++) // Rows 1-8 instead of 0-7 9.1.7 Checkerboard V2 Codehs

Some CodeHS courses use a console-based "ASCII art" version. This uses text characters instead of graphics.

Think of the board as a grid. You need to iterate over each row, and within each row, over each column.

def print_board(board): for row in board: print(" ".join(str(cell) for cell in row)) Start by defining the size of the board and the squares

: Use an outer loop to move down the rows and an inner loop to place squares across the columns.

x_pos = c * SQUARE_SIZE : Moves the drawing pen to the right as the column index increases.

var x = row * 50; // Swapped row and col This uses text characters instead of graphics

Remember: x = col * size , y = row * size . The column determines horizontal position (x), the row determines vertical position (y).

Start by defining the size of your board and the colors you want to use. This makes your code easier to read and modify later. javascript