Build a Password Generator App - Running code doesn't pass the tests

Tell us what’s happening:

My code runs fine when I run it VS code but i can’t pass this lab? what’s wrong?

My code so far

function generatePassword(length){
    const characters="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#£$%^&*~()_+[]{}`¬"
    let password = ""
    const arrayLength = characters.length
    for(let i =0;i<length;i++){
       let randomIndex =Math.floor(Math.random()*(arrayLength)+0)
       password+=characters[randomIndex]
    }
    return password
}
let password=generatePassword(10)
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/138.0.0.0 Safari/537.36

Challenge Information:

Build a Password Generator App - Build a Password Generator App
https://www.freecodecamp.org/learn/full-stack-developer/lab-password-generator/lab-password-generator

here’s a link to a Programiz page w my code to prove that it works

Programiz Code

Here are some basic troubleshooting steps you can follow. Focus on one test at a time:

  • What is the requirement for the first failing test?
  • Double check the related User Story and ensure it’s followed precisely.
  • What line of code is involved?
  • What is the result of the code and does it match the requirement? You can write the value of a variable to the console at that point in the code to check if needed.
  • Is there any other output or messages in the console to follow up on?

If this does not help you solve the problem, please reply with answers to these questions.

the code in your Programiz and the code you posted are slightly different

In what way? I don’t remember making any changes icl

the last line of the code you shared in this topic

You should check your characters variable, as its value doesn’t match the string specified in the challenge instructions.

Even after fixing that (and the syntax error previously mentioned), there is an issue, which I think needs to be reported, if it hasn’t been already? I had to add a semi-colon at the end of the password declaration line, as the code wouldn’t pass without it.

the fix is in progress

EDIT, the fix is in, next deployment it will be live

2 Likes

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.