Skip to content

Instantly share code, notes, and snippets.

@ddeveloperr
Created March 29, 2015 09:18
Show Gist options
  • Save ddeveloperr/4958e998a852968d2ac0 to your computer and use it in GitHub Desktop.
Save ddeveloperr/4958e998a852968d2ac0 to your computer and use it in GitHub Desktop.
Write a program that creates a string that represents an 8×8 grid
/*Write a program that creates a string that represents an 8×8 grid, using newline characters to separate lines. At each position of the grid there is either a space or a “#” character. The characters should form a chess board.*/
var size = 8;
var board = "";
for (var y =0; y< size; y++) {
for(var x =0; x< size; x++){
if ((x+y) %2 ===0)
board += " ";
else
board += "#";
}
board += "\n";
}
console.log(board);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment