Design comparison
Solution retrospective
Hope this could be your daily real password generator app ð
Community feedback
- @FexxixPosted over 1 year ago
I think it's pretty good but its overflowing on my screen so might wanna look into that.
this is just extra stuff since it's not letting me comment with a comment this short.
Try adding an
Exclude Duplicate
and anInclude Spaces
option. I made a password generator just like this when I started out and the exclude duplicate option was kind of tough for me as a beginner. I would like to see how you implement it in to your code as an experienced front end coder.Marked as helpful1@SppamLitePosted over 1 year agoHi @Fexxix , thank you for your valuable comment! I fixed the overflow issue with
text-overflow: ellipsis;
. It won't be a problem for copying it.To remove the duplicate characters from the password, what you could do is
- split the password string into a characters-array:
passArr = password.split('');
- get unique characters array:
uniqChars = [...new Set(passArr)];
- now the tricky part is that you need to fill the
uniqChars
array with random non-repeat characters to fulfill the length requirement. You could make a while loop, every time you loop through, you get a random character and see if that generated character is included in thatuniqChars
array (uniqPass.includes(gendChar);
, if it is, keep going the loop until it hits false.
I hope the steps above explained why I don't implement it in my code ð, plus duplicate shouldn't make your password weaker.
Include Spaces
is another controversial topic on the internet ð However I just don't like space or tab in my password string since it doesn't look pretty ðĪŠI hope my answer above helps, thanks for your comment again and happy coding!
0@FexxixPosted over 1 year ago@SppamLite That is certainly a good approach but what I did was that I used a two dimensional array to store all the character sets the user wanted and then i used the
array.flat()
method on it and then I usedarray.splice()
method (if the user had selectedexclude duplicate
) to delete the element every time a character was added to the password from the array so it wouldn't repeat. I also utilized a guard clause for preventing the situation where the user was demanding duplicate characters with a password length for which the character sets weren't long enough. For example, making a 12 char password with only numbers.What do you think about my approach.
0@SppamLitePosted over 1 year ago@Fexxix I don't think you need the two-dimensional array since you flat them anyway, just a simple array should be good. I don't mind use
array.splice()
, however personally I preferarray.slice()
because it won't modify the original array.0 - split the password string into a characters-array:
Please log in to post a comment
Log in with GitHubJoin 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