Password Generator with JavaScript
For the password creation, JavaScript was used to create variables, formulas as well as prompts to obtain the user's spefication. Depending on the user's answers, these are stored in a bolean variable and at the end, depending on the answers, is the char string that wil be used which contains normal, upper, special and number characters. Additiionally for each question answered as yes, a variable of that type will be selected at random and then substracted at the end fromt he Password Length. If one of the users answers ommits one of the set of characters, these are not used and the counter is not added and at the end, the combination of answers will create the password..
There are 14 scenarios in the application which are:
| Scenario | Lower Case | Upper Case | Special Characters | Number Case | Outcome |
|---|---|---|---|---|---|
| 1 | Yes | Yes | Yes | Yes | All Variables |
| 2 | No | Yes | Yes | Yes | Upper Case, Special Characters and Numbers |
| 3 | Yes | No | Yes | Yes | Lower Case, Special Characters and Numbers |
| 4 | Yes | Yes | No | Yes | Lower Case, Upper Case and Numbers |
| 5 | Yes | Yes | Yes | no | Lower Case, Upper Case and Special Characters |
| 6 | No | No | Yes | Yes | Special Characers and Numbers |
| 7 | Yes | No | No | Yes | Lower case and Numbers |
| 8 | Yes | Yes | No | No | Lower Case and Upper Case |
| 9 | No | Yes | Yes | No | Upper Case and Special Characters |
| 10 | No | No | No | Yes | Numbers Only |
| 11 | Yes | No | No | No | Lower Case Only |
| 12 | No | Yes | No | No | Upper Case Only |
| 13 | No | No | Yes | No | Special Characters Only |
| 14 | No | No | No | No | No Characters but function restarts asking for at least 1 variable |
For the password length, condicionals were used to only allow the user to select a password between 8 and 128 characters. If the user provides a number below or above the stipulated, an alert command will pop up stating that they need to select a password length between 8 and 128 and will restart the process again.
The formula to get the random number was partially obtained in Overstack Overflow however the way it works is that we use the random command to get a random number between 0 and 1 and then its rounded up using the floor command. Afterwards, it is multiplied by the char set length in order to have more probabilities rather than the password length.
During this challenge I learned to use JavaScript a bit more however, I am sure the code can be otpmized, specially with the combination of answers fromt the user. It was challenging but fun at the same time.
How the webpage should look when opening:
How the webpage should look when you click on the generate password and all variables are true and with 8 character long password
Link to github pages