vendredi 15 janvier 2021

hello, I would like to have a different random number, but I always get the same, an idea?

I want to have a random number different when I "click" on my button #roll, but I always get the same number. someone could help me please?

this is my code:

//création nombre aléatoire
function getRandomInt(min, max) {
  return Math.floor(Math.random() * (max, min + 1)+ min);
}
numberRandom = getRandomInt(1, 7)

//création du lancé de dé
const roll = document.getElementById("roll")
roll.addEventListener('click',()=>{
  alert(numberRandom)
})
          <button class="favorite styled" type="button" id="roll">
          Lancer le dé
          </button>



Aucun commentaire:

Enregistrer un commentaire