Build a Password Generator App - Build a Password Generator App

Tell us what’s happening:

function generatePassword(length) {
const characters = “ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()”;
let password = “”;
for (let i = 0; i < length; i++) {
const randomIndex = Math.floor(Math.random() * characters.length);
password += characters.charAt(randomIndex);
}
return password;
}
let password = generatePassword(8);
console.log(“Generated password:”, password);
the console part is not working

Your code so far

function generatePassword(length) {
    const characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()";
    let password = "";
    for (let i = 0; i < length; i++) {
        const randomIndex = Math.floor(Math.random() * characters.length);
        password += characters.charAt(randomIndex);
    }
return password;
}
let password = generatePassword(8);
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/136.0.0.0 Safari/537.36

Challenge Information:

Build a Password Generator App - Build a Password Generator App

I think the test should allow your code, but you will pass if you use the concatenation operator in your console.log, instead of a comma.

So we need to use concatenation instead of template sting

Use concatentation here, instead of a comma:

Oh i got it you say + with variable name

1 Like

Thanks for you compliment

1 Like

I got the result and it is good