const characters = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T",
"U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s",
"t","u","v","w","x","y","z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9","~","`","!","@","#",
"$","%","^","&","*","(",")","_","-","+","=","{","[","}","]",",","|",":",";","<",">",".","?",
"/"];
// change to const
let outputElOne = document.getElementById("output1-el")
let outputElTwo = document.getElementById("output2-el")
let passwordLength = 15
// Returns a random integer from 0 to 9:
// console.log(Math.floor(Math.random() * 10))
generateButton.addEventListener("click", function() {
function getRandomCharacter() {
// change to const
let randomChar = Math.floor(Math.random() * characters.length)
// check length of array:
// console.log(characters.length)
// generate random number which represents the number of the index
// console.log(randomChar, characters[randomChar])
return characters[randomChar]
}
function generateRandomPassword() {
// keep as let - this value is always being updated
let randomPassword = ""
for (let i = 0; i < passwordLength; i++) {
// password length is 15; output will be 0 through 14
randomPassword += getRandomCharacter()
// iterate through the length of 15 and run getRandomCharacter()
// console.log(i, randomPassword)
}
return randomPassword
}
const generatedPasswordOne = generateRandomPassword()
const generatedPasswordTwo = generateRandomPassword()
outputElOne.textContent = generatedPasswordOne
outputElTwo.textContent = generatedPasswordTwo
// final output of each generated password
// console.log(generatedPasswordOne)
// console.log(generatedPasswordTwo)