I want my function to check if there is an element with no content in it first, then if the condition is true- execute the code, else don't run the function. I just don't know how to check whether there is an element with no content in it.
function randomBlock(){
let random = Math.floor(Math.random() * blocks.length)
if(blocks[random].textContent == ""){
blocks[random].textContent = "O"
} else{
randomBlock()
}
}
Aucun commentaire:
Enregistrer un commentaire