Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted about 1 month ago

Password Generator

sass/scss
P
Emmanuel Lopez•480
@EmLopezDev
A solution to the Password generator app challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


What are you most proud of, and what would you do differently next time?

I am most proud of the fact that I actually finished it and got it to work. There were moments I felt like giving up like when trying to figure out how to generate the random password based on the inputs, but I stuck it out and did it. I also am proud of taking the extra steps to add disabled states to the buttons just for a better user experience.

What challenges did you encounter, and how did you overcome them?
  • Adding custom styles to the input range was bit of a challenge but luckily I found a good resource to help.
  • Randomizing the characters for the password was a challenge because it involved a fair amount of logic, however through a bunch of trial and error I got it to work.
What specific areas of your project would you like help with?

I definitely would like feedback on the JavaScript.

I cleaned up the logic as much as I think I could but I am sure there is more I could have done or a better approach.

Would like feedback in general on the file but for a bit more specificity these two logics:

const randomCharacter = () => {
    finalPW = "";
    const checked = isChecked(checkedOptions);
    while (finalPW.length < lengthValue) {
        const randomIndex = randomNumber(checked.length);
        const randomCategory = checked[randomIndex];
        const categoryValues = passwordCharacters[randomCategory];
        const randomCharAt = randomNumber(categoryValues.length + 1);
        const randomCharacter = categoryValues.charAt(randomCharAt);
        finalPW += randomCharacter;
    }
};

const finalPwStrength = () => {
    const checkedLength = isChecked(checkedOptions).length;
    if (lengthValue < 15 && checkedLength === 1) {
        changeGauges(1, "very weak");
    } else if (lengthValue < 15 && checkedLength === 2) {
        changeGauges(2, "weak");
    } else if (lengthValue < 15 && checkedLength > 2) {
        changeGauges(3, "medium");
    } else if (lengthValue >= 15 && checkedLength === 1) {
        changeGauges(2, "weak");
    } else if (lengthValue >= 15 && checkedLength === 2) {
        changeGauges(3, "medium");
    } else {
        changeGauges(4, "strong");
    }
};
Code
Loading...

Please log in to post a comment

Log in with GitHub

Community feedback

No feedback yet. Be the first to give feedback on Emmanuel Lopez's solution.

Join our Discord community

Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!

Join our Discord
Frontend Mentor logo

Stay up to datewith new challenges, featured solutions, selected articles, and our latest news

Frontend Mentor

  • Unlock Pro
  • Contact us
  • FAQs
  • Become a partner

Explore

  • Learning paths
  • Challenges
  • Solutions
  • Articles

Community

  • Discord
  • Guidelines

For companies

  • Hire developers
  • Train developers
© Frontend Mentor 2019 - 2025
  • Terms
  • Cookie Policy
  • Privacy Policy
  • License