Skip to content

Instantly share code, notes, and snippets.

@xqft
Created July 27, 2022 23:48
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 xqft/fa547c6c8f8a951fc0fc991be3459b99 to your computer and use it in GitHub Desktop.
Save xqft/fa547c6c8f8a951fc0fc991be3459b99 to your computer and use it in GitHub Desktop.
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