Created
April 23, 2022 23:39
-
-
Save arelthia/97e0b17439b8a8dfb08dd48c1e5547f8 to your computer and use it in GitHub Desktop.
Wordle Grid
This file contains 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
let grid = document.querySelector("#game"); | |
// the number of guesses | |
let guessesAllowed = 4; | |
// the length of the word | |
let wordLength = 3; | |
// generate 3 rows | |
let fragement = document.createDocumentFragment(); | |
let generateGrid = () => { | |
// where each row contains 3 columns | |
Array.from({length: guessesAllowed}).forEach(() => { | |
let row = document.createElement('div'); | |
row.classList.add('row'); | |
Array.from({length: wordLength}).forEach(() =>{ | |
let tile = document.createElement('div'); | |
tile.classList.add('tile'); | |
row.appendChild(tile); | |
}); | |
fragement.appendChild(row); | |
}); | |
//append to the grid | |
grid.append(fragement); | |
} | |
generateGrid(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment