I am using window prompts and window.confirm to ask the user if they want to use certain characters in their password. (I know I can do checkboxes with some HTML, but this must be JS). How do I pass the confirm answers to the function and then use Math.floor(Math.random() * length)
?
const key_strings = {
lowercase: 'abcdefghijklmnopqrstuvwxyz',
uppercase: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
number: '0123456789',
symbol: " !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~",
};
function generatePassword() {
passwordCharSet = "";
var length = window.prompt("Enter a number from 8 to 128 for password length.");
var lowercase = window.confirm("Would you like to use lowercase letters?");
if (lowercase == true) {
passwordCharSet += lowercase;
};
var uppercase = window.confirm("Would you like to use uppercase letters?");
if (uppercase == true) {
passwordCharSet += uppercase;
};
var symbols = window.confirm("Would you like to use symbols?");
if (symbols == true) {
passwordCharSet += symbols;
};
var numbers = window.confirm("Would you like to use numbers?");
if (numbers == true) {
passwordCharSet += numbers;
};
for (let i = 0; i < length; i++) {
_______________ Math.floor(Math.random() * length)
}
}
I'm not sure what else to put with the math.floor either.
Aucun commentaire:
Enregistrer un commentaire