Last active
September 20, 2019 12:47
-
-
Save johnhutchins/895fc9a49bd475f8a5a14ac4b6fb1181 to your computer and use it in GitHub Desktop.
create grid of any size, where each line is offset
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
function chessBoard(sizeOfBoard){ | |
const board = sizeOfBoard; | |
for(let i=0;i<board;i++){ | |
let evenPrintout = '#'; | |
let oddPrintOut = ' #'; | |
if(i === 0){ | |
oddPrintOut = oddPrintOut; | |
} | |
if(i % 2 != 0){ | |
console.log(oddPrintOut.repeat(sizeOfBoard)); | |
} | |
if(i % 2 === 0){ | |
if(i === 2){ | |
evenPrintout = evenPrintout; | |
} | |
for(let j=0;j<board;j++){ | |
evenPrintout += ' #'; | |
} | |
console.log(evenPrintout); | |
} | |
} | |
} | |
chessBoard(44); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment