Skip to content

Instantly share code, notes, and snippets.

@johnhutchins
Last active September 20, 2019 12:47
Show Gist options
  • Save johnhutchins/895fc9a49bd475f8a5a14ac4b6fb1181 to your computer and use it in GitHub Desktop.
Save johnhutchins/895fc9a49bd475f8a5a14ac4b6fb1181 to your computer and use it in GitHub Desktop.
create grid of any size, where each line is offset
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