There is an error in your code:
const characterIndex = Math.round(Math.random() * CharacterListLength);
It should be Math.floor otherwise you may end up with an index the same as the CharacterListLength and that would be an invalid index.
Math.floor
CharacterListLength
Also it is a good practice to share a jsfiddle codepen etc so people can play with your code.
Either way, it looks nice! ❤
Math.random() is not cryptographically secure and must not be used to generate passwords. Instead, use Crypto.getRandomValues().
Math.random()
Thank you so much bro now it's working properly
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
There is an error in your code:
const characterIndex = Math.round(Math.random() * CharacterListLength);
It should be
Math.floor
otherwise you may end up with an index the same as theCharacterListLength
and that would be an invalid index.Also it is a good practice to share a jsfiddle codepen etc so people can play with your code.
Either way, it looks nice! ❤
Math.random()
is not cryptographically secure and must not be used to generate passwords.Instead, use Crypto.getRandomValues().
Thank you so much bro
now it's working properly