mercredi 21 juillet 2021

How to reset a randomly generated number again after a click using JavaScript?

So, basically, I am trying to generate a password when I click a button. The program generating the password once but when I click it again due to the fact that a new Randomized number isn't generated the program doesn't give a new password. Here is the CODE:

    let password  = ["NyiNE7!38vs","SyiMA4*78dt","SuoSO6]40db","LeaDU9'11ln","QooGU9!09nk","SeuXI1_63sp","SieKY6)07zk","GaaDI9'30gn","BoyLY4|74ct","BuaZI0+69vl"]
  function Random() {
let i = Math.floor(Math.random() * 9)
}
 i = Math.floor(Math.random() * 9)
const div = document.getElementById('password')
const button = document.getElementById('generate')
button.addEventListener('click' , generatePassword , Random)
function generatePassword(){
div.innerHTML = password[i]
}



Aucun commentaire:

Enregistrer un commentaire