dimanche 25 septembre 2022

random number javascript onclick doesn't work

I'm trying to use setTimeout.

Without setTimeout my function works,but using setTimeout it stops. Any one knows what I am doing wrong? I want that function works only 3 seconds after click.

let d6
document.getElementById("rollButton").onclick = function d6click(){
d6 = Math.floor(Math.random() * 6) + 1;
document.getElementById("resultd6").innerHTML = d6;
};
setTimeout(d6click, 3000)



Aucun commentaire:

Enregistrer un commentaire