Generate a password depending on the user specifications
-
On click, run a writePassword() function that will get user input on the length of the password desired, and whether they wish to use upper case, lower case, numeric and special characters.
-
Verify that they do not enter a non-integer.
-
Verify that they only enter a length between 8 and 128 chars.
-
Verify that they make at least one option choice.
-
Once all options are set, generate password.
-
Display new password in textarea on screen.
-
Decided to add a reset function to reset object so that they can generate many different passwords with different options as desired. As it was, the when you clicked on the button again, it just generated a new password from the same options. Asked the user if they wanted to change options! If so, it recurses through the function again.
Methods:
- Create a settings object to hold all settings.
- Create strings with appropriate characters.
- Create an array of options to choose from (i.e., upper, lower, etc.).
- Use Math.floor() and Math.random() to a) select an option, and b) select a random character from the option list.
- Add the random character to the password.
- Iterate through a loop to get as many random characters as needed.
- Use event listener to check for click events.
- Use getElementById to get the text area and write the new password.
To see original requirements, look at the readme.md in the assets/requirements folder.