Build a Password Generator App - Build a Password Generator App

Tell us what’s happening:

I am getting a test case failure for 9. You should log the generated password for the console.

Your code so far

function generatePassword(length) {
  const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()";
  let result = "";

  for (let i = 0; i < length; i++) {
    const randomIndex = Math.floor(Math.random() * chars.length);
    result += chars[randomIndex];
  }

  return result;
}

const password = generatePassword(12);

console.log("Generated password:", password);

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36

Challenge Information:

Build a Password Generator App - Build a Password Generator App

you need to print a single string

That fixed it! Thank you so much!