From 8d404b973aaf2891a5b7cbfced73f1602094eb78 Mon Sep 17 00:00:00 2001 From: David Nelson Murray Date: Tue, 7 Aug 2018 19:08:04 -0500 Subject: [PATCH] got the tiles working! --- script.js | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/script.js b/script.js index 9233771b..81720684 100644 --- a/script.js +++ b/script.js @@ -1 +1,41 @@ -// Your JS goes here \ No newline at end of file +// Your JS goes here +document.addEventListener('DOMContentLoaded', () => { + + let colorToggle = 0; + for (let j=0; j < 4; j++) { + for (let i = 0; i < 8; i++) { + colorToggle ++; + const tile = document.createElement('div'); + document.body.appendChild(tile); + if (colorToggle % 2 === 0) { + tile.style.backgroundColor = 'red'; + } else { + tile.style.backgroundColor = 'black'; + }; + tile.style.cssFloat = 'left'; + tile.style.width = '11.1%' + tile.style.height = '100px'; + tile.style.margin = '1px'; + tile.style.borderColor = 'black' + // tile.textContent = colorToggle; + }; + colorToggle -= 1; + for (let i = 0; i < 8; i++) { + colorToggle ++; + const tile = document.createElement('div'); + document.body.appendChild(tile); + if (colorToggle % 2 === 0) { + tile.style.backgroundColor = 'red'; + } else { + tile.style.backgroundColor = 'black'; + }; + tile.style.cssFloat = 'left'; + tile.style.width = '11.1%' + tile.style.height = '100px'; + tile.style.margin = '1px'; + tile.style.borderColor = 'black' + // tile.textContent = colorToggle; + }; + colorToggle ++; + }; +}) \ No newline at end of file