Created
July 27, 2022 23:48
-
-
Save xqft/fa547c6c8f8a951fc0fc991be3459b99 to your computer and use it in GitHub Desktop.
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
window.addEventListener('DOMContentLoaded', () => { | |
const container = document.querySelector(".board"); | |
for(let i = 0; i <= 63; i++) { | |
const cell = document.createElement("div"); | |
const index = Math.floor(i + i/8); // numero de celda + numero de fila | |
cell.classList.add(isEven(index) ? "white" : "black"); | |
container.append(cell); | |
} | |
}); | |
function isEven(n) { | |
return n % 2 === 0; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment