News

If you are working through the CodeHS curriculum, you’ve likely encountered the assignment. It’s a classic challenge that tests your ability to use nested loops, coordinate systems, and conditional logic.

Toggling a boolean variable at the end of the inner loop without accounting for whether the row length is even or odd. If your grid width is an even number (like 8x8), toggling a boolean at the end of a row makes the next row start on the exact same color.

After implementing the code above, run the program. You should see:

If you’ve landed on this article, chances are you’re stuck on the problem in the CodeHS Java (or sometimes JavaScript Graphics) course. You’ve tried writing the code, but the checkerboard isn’t rendering correctly—maybe the colors are wrong, the rows aren’t alternating, or the squares aren’t aligned.

In the landscape of introductory computer science, few tools are as effective for teaching logic as the CodeHS graphics library. Among the classic exercises presented to students is the creation of a checkerboard—a seemingly simple visual pattern that actually requires a deep understanding of coordinate systems, iteration, and conditional logic. The "916 Checkerboard v1" assignment is a specific variation of this problem that often trips up beginners. A "fixed" version of this code does more than just produce a pretty picture; it demonstrates the fundamental shift from linear thinking to algorithmic problem-solving.

This public link is valid for 7 days and shares a thread, including any personal information you added. This link or copies made by others cannot be deleted. If you share with third parties, their policies apply. Can’t copy the link right now. Try again later.

The most common "non-fixed" issues students encounter:

Using a simple boolean toggle (like isRed = !isRed ) at the end of the inner loop causes an error at the start of every new row. Because a standard checkerboard has an even number of columns, the last square of Row 1 and the first square of Row 2 end up being the exact same color, creating solid vertical stripes instead of a checkered pattern. 3. Loop Boundary Errors

If your original code was failing the CodeHS autograder, it likely suffered from one of three common architectural flaws: 1. The Ovens vs. Evens Row Problem

916 checkerboard v1 codehs fixed