Build a Password Generator App - Build a Password Generator App

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

Where is user story 3 in your code?

Sorry, I have been trying multiple different ways. This is what I have currently and it is still not passing #3 or #9

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));
  }
  return results;    
}
let password = generatePassword();
console.log(`Generated password: ${password}`);

console.log(generatePassword(4));
console.log(generatePassword(6))

Sorry I solved it now! I was not creating a new string, I was concatenating the password. Thank you.