Skip to content

Instantly share code, notes, and snippets.

@EvanGertis
Created February 1, 2019 14:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EvanGertis/f5ed9d8041df6b69d0622d385e8d4ddc to your computer and use it in GitHub Desktop.
Save EvanGertis/f5ed9d8041df6b69d0622d385e8d4ddc to your computer and use it in GitHub Desktop.
let body = document.getElementsByTagName("body");
// global variables to set color
let color = "";
let color_one = "red";
let color_two = "black";
// square size parameters.
let square_width = "100px";
let square_height = "100px";
// grid size parameters.
let rows = 6;
let cols = 6;
// main entry point for the program
main();
function main(){
// loop down the rows.
for(let i = 0; i < rows; i++){
// container for the row.
let UI_body = UI_box(String(i));
// loop across the columns.
for(let j = 0; j < cols; j++){
if(j % 2 == 0 && i %2 == 0){
color = color_one;
}
else {
color = color_two;
if(i % 2 != 0 && j % 2 != 0){
color = color_one;
}
}
// generates a parameterized square and attaches it to the UI_box container.
square(UI_body, square_width, square_height, color);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment