Created
March 29, 2015 09:18
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*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