Build a Password Generator App - Build a Password Generator App

Tell us what’s happening:

Hi there,
I have written the code to the best of my ability and double checked, but it has failed to pass. It is stating:
You should call the generatePassword function with a numeric argument and store the returned password in the password variable.

Your code so far

function generatePassword (lengthPar) {

  let result = "";

  let collectArray = [];

  const variousChar = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()";


  for(let i = 0; i < lengthPar; i++) {

    const randomNumber = Math.floor(Math.random() * variousChar.length);
   
      collectArray.push(variousChar[randomNumber]);
  
  }
  result = collectArray.join("");

  return result;
}

 let password = generatePassword (3);

 console.log(`Generated password: ${password}`);
 
 

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

  • fix your function call there is a space between function name and parenthesis

address that change and try again, happy coding :slight_smile:

1 Like

Thank you! My code finally passed.:+1:

1 Like