mannymcfly
mannymcfly

Reputation: 1

How to schedule page updates rather than on refresh

I am new to Javascript so bare with me. I am working on a Wordle Clone and everytime I refresh the page, the game selects a new word from my array of words. I am wondering if there is a way to make it only do this once per day (at midnight perhaps). This way, I have a daily wordle and, if I refresh, it won't change the word.

Here is my function that sets up the board. I tried setInterval(initBoard(),3600000*24) but it did not work.

function initBoard() {
    let board = document.getElementById("game-board");

    for (let i = 0; i < NUMBER_OF_GUESSES; i++) {
        let row = document.createElement("div")
        row.className = "letter-row"
        
        for (let j = 0; j < rightGuessString.length; j++) {
            let box = document.createElement("div")
            box.className = "letter-box"
            row.appendChild(box)
        }

        board.appendChild(row)
    }
}

Upvotes: 0

Views: 82

Answers (0)

Related Questions