Getting started

Hints & tips

9.1.7 Checkerboard V2 Codehs May 2026

This essay explores the logic and implementation of the Checkerboard V2 challenge in the CodeHS 9.1.7 curriculum

  1. The board size is variable (e.g., a ROWS and COLUMNS constant, or user input).
  2. You must use a single nested loop and decide square color based on (row + column) % 2.

Master this, and you have unlocked a fundamental pattern used in game development, graphics programming, and algorithm design.

var x = col * SQUARE_SIZE; var y = row * SQUARE_SIZE; var square = new Rectangle(SQUARE_SIZE, SQUARE_SIZE); square.setPosition(x, y); // The "Checkerboard" Logic if ((row + col) % 2 == 0) square.setColor(COLOR_ONE); else square.setColor(COLOR_TWO); add(square); Use code with caution. Common Pitfalls to Avoid

Final Tips

Since I can't see your specific assignment screen, I'll provide a general solution and explanation for drawing a checkerboard pattern, which is a common exercise in CodeHS's JavaScript Graphics unit.

If (row + column) % 2 == 0 → Color A.
If (row + column) % 2 == 1 → Color B.

This essay explores the logic and implementation of the Checkerboard V2 challenge in the CodeHS 9.1.7 curriculum

  1. The board size is variable (e.g., a ROWS and COLUMNS constant, or user input).
  2. You must use a single nested loop and decide square color based on (row + column) % 2.

Master this, and you have unlocked a fundamental pattern used in game development, graphics programming, and algorithm design.

var x = col * SQUARE_SIZE; var y = row * SQUARE_SIZE; var square = new Rectangle(SQUARE_SIZE, SQUARE_SIZE); square.setPosition(x, y); // The "Checkerboard" Logic if ((row + col) % 2 == 0) square.setColor(COLOR_ONE); else square.setColor(COLOR_TWO); add(square); Use code with caution. Common Pitfalls to Avoid

Final Tips

Since I can't see your specific assignment screen, I'll provide a general solution and explanation for drawing a checkerboard pattern, which is a common exercise in CodeHS's JavaScript Graphics unit.

If (row + column) % 2 == 0 → Color A.
If (row + column) % 2 == 1 → Color B.