Created
June 19, 2019 07:46
-
-
Save neur0manc/34591ad2c98a7d12e45c859f15e166a9 to your computer and use it in GitHub Desktop.
Eloquent JavasScript Rev.3 :: Chapter 2 :: Checkerboard Exercise
This file contains hidden or 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
const size = 8 | |
let output = "" | |
let currentChar = "#" | |
for (let _ = 1; _ <= size; _ += 1) { | |
let line = "" | |
currentChar = currentChar === "#" ? " " : "#" | |
for (let __ = 1; __ <= size; __ += 1) { | |
line += currentChar | |
currentChar = currentChar === "#" ? " " : "#" | |
} | |
output += `${line}\n` | |
} | |
console.log(output) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment