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