I want to generate random number then use it as an index of a node list and if the element has no text in it it should write "O", if the element has text in it it should search for a new random number until it gets to an element with no text in it. For some reason, the function never displays "O". Why is that?
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