Created
February 18, 2015 11:05
-
-
Save ralphking/9265cf964b4002b91b39 to your computer and use it in GitHub Desktop.
JS chess board. Useful for two dimensional loops
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
// set your board size | |
var size = "64"; | |
// initialize empty string | |
var string = ""; | |
// loop the sucker | |
for (var i = 0; i < size; i++) { | |
for (var j = 0; j < size; j++) { | |
if ((i + j) % 2 == 0) { | |
string += " "; | |
} else { | |
string += "#"; | |
} | |
} | |
string += "\n"; | |
} | |
// print out your chess board | |
console.log(string); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment