Created
October 25, 2017 17:24
-
-
Save elevenpassin/2b5151baaafd21b1c1069f503a2b58c8 to your computer and use it in GitHub Desktop.
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
/* | |
A program that creates a string that represents an 8 x 8 grid, using newline characters to separate lines. | |
At each position of the grid there is either a space or a "#" character. | |
The characters printed should represent a chessboard. | |
*/ | |
function printChessBoard(size){ | |
let odd = false; | |
for(var i=0; i < size; i++){ | |
let newline = ''; | |
for(var j=0; j < size/2; j++){ | |
newline += odd ? ' #' : '# ' | |
} | |
odd = !odd; | |
console.log(newline); | |
} | |
} | |
module.exports = { | |
printChessBoard : printChessBoard | |
} |
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
/* | |
A program that creates a string that represents an 8 x 8 grid, using newline characters to separate lines. | |
At each position of the grid there is either a space or a "#" character. | |
The characters printed should represent a chessboard. | |
*/ | |
function printChessBoard(size){ | |
let odd = false; | |
for(var i=0; i < size; i++){ | |
let newline = ''; | |
for(var j=0; j < size/2; j++){ | |
newline += odd ? ' #' : '# ' | |
} | |
odd = !odd; | |
console.log(newline); | |
} | |
} | |
module.exports = { | |
printChessBoard : printChessBoard | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment