Skip to content

Instantly share code, notes, and snippets.

@Billboz
Created May 28, 2015 00:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Billboz/8183f7db201db69601db to your computer and use it in GitHub Desktop.
Save Billboz/8183f7db201db69601db to your computer and use it in GitHub Desktop.
Eloquent Javascript Chapter 2 Chess Board Solution and Explanation
var board = "";
for (var y = 0; y < size; y++)
{
console.log("Inside the for-y loop and y is " + y);
for (var x = 0; x < size; x++)
{
console.log("Inside the for-x loop and x is " + x);
if ((x + y) % 2 == 0)
board += " ";
else
board += "#";
console.log("At the bottom of the for-x loop and x is " + x);
}
board += "\n";
console.log("At bottom the for-y loop and y is " + y);
}
console.log(board);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment