Build a Password Generator App

Well, I’m stumped! Why do you think this test isn’t passing? Thank you!

  1. You should call the generatePassword function with a numeric argument and store the returned password in the password variable.

Here’s my code:

function generatePassword(passLength) {
  let password = '';
  const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()"
  for (let i = 0; i < passLength; i++) {
      password = password + chars[Math.floor(Math.random() * (chars.length))]
  }
  return password;
}


let password = generatePassword(16)
console.log(`Generated password: ${password}`)

// console output
Generated password: 544B9#wbbp!xOoD8

Browser info: Safari Version 18.5

Just fixed it, check semicolons people.

1 Like