vendredi 2 septembre 2022

Why Math.random method does not work in my case

I am using the Dom domination to create a function that will be executed if someone clicks the button 'again'. The function is about creating a new random number that is assigned to the 'secret' variable. Unfortunately, when I click the button 'again' on the website, the value of the 'secret' variable does not change. Somebody help me, please!

let secret = Math.trunc(Math.random() * 20) + 1;
document.querySelector('.again').addEventListener('click', function () {
  secret = Math.trunc(Math.random() * 20) + 1;
});



Aucun commentaire:

Enregistrer un commentaire