Skip to content

Instantly share code, notes, and snippets.

@brunojppb
Last active January 22, 2016 15:26
Show Gist options
  • Save brunojppb/c936eb721ae14a0942cd to your computer and use it in GitHub Desktop.
Save brunojppb/c936eb721ae14a0942cd to your computer and use it in GitHub Desktop.
var createChess = function (width, height){
for(var i = 1; i <= height; i++){
var line = "";
for(var j = 0; j < width; j++){
var newChar = "";
if(i % 2 == 0){
newChar = (j % 2) == 0 ? "#" : " ";
} else {
newChar = (j % 2) != 0 ? "#" : " ";
}
line += newChar;
}
console.log(line);
}
}
createChess(8,8);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment