Created
May 11, 2020 23:59
-
-
Save JFFail/797003f14dcf362ecd65fd6e6c4fac4a to your computer and use it in GitHub Desktop.
Simple chessboard-generating script from Eloquent JavaScript Chapter 2.
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
var size = 15, base = ""; | |
for(var i = 1; i <= size; i++) { | |
if(i % 2 === 1) { | |
for(var k = 1; k <= size; k++) { | |
if(k % 2 === 1) { | |
base += "#"; | |
} else { | |
base += " "; | |
} | |
} | |
} else { | |
for(var k = 1; k <= size; k++) { | |
if(k % 2 === 1) { | |
base += " "; | |
} else { | |
base += "#"; | |
} | |
} | |
} | |
if(i < size) { | |
base += "\n"; | |
} | |
} | |
console.log(base); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment