Tell us what’s happening:
#3 and #9 are not passing. I do not understand what I am doing wrong. The generated password is the correct length, is it just not a string? I thought that by putting “password = results” that I would be storing the returned password in the password variable? Please help!
Your code so far
let password = ``;
let results = ``;
function generatePassword(passwordLength) {
let characters = `ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()`;
let characterLength = characters.length;
for (let i = 0; i < passwordLength; i++) {
results += characters.charAt(Math.floor(Math.random() * characterLength));
password = `${results}`;
}
return password;
}
console.log(`Generated password: ${password}`);
console.log(generatePassword(4));
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36
Challenge Information:
Build a Password Generator App - Build a Password Generator App