@@ -5,24 +5,30 @@ Math.floor() function returns the largest integer less than or equal to a given
55For generating a random uppercase lowercase text random numbers symbols we use Charcode
66http://stevehardie.com/2009/09/character-code-list-char-code/ */
77
8+
9+ // getRandomLower(): This function returns a random lowercase letter using the Unicode character code.
810function getRandomLower ( ) {
911 return String . fromCharCode ( Math . floor ( Math . random ( ) * 26 ) + 97 ) ;
1012}
1113
14+ // getRandomUpper(): This function returns a random uppercase letter using the Unicode character code.
1215function getRandomUpper ( ) {
1316 return String . fromCharCode ( Math . floor ( Math . random ( ) * 26 ) + 65 ) ;
1417}
1518
19+ // getRandomNumber(): This function returns a random number using the Unicode character code.
1620function getRandomNumber ( ) {
1721 return + String . fromCharCode ( Math . floor ( Math . random ( ) * 10 ) + 48 ) ;
1822}
1923
24+ // getRandomSymbol(): This function returns a random symbol from a predefined list of symbols.
2025function getRandomSymbol ( ) {
2126 const symbols = "!@#$%^&*(){}[]=<>/,." ;
2227 return symbols [ Math . floor ( Math . random ( ) * symbols . length ) ] ;
2328}
2429
2530// adding a all functions into a object called randomFunc
31+ // An object randomFunc is created to store references to the above functions.
2632const randomFunc = {
2733 lower : getRandomLower ,
2834 upper : getRandomUpper ,
@@ -49,7 +55,7 @@ generate.addEventListener("click", () => {
4955 // console.log(hasLower, hasUpper, hasNumber, hasSymbol);
5056} ) ;
5157
52- // function for generating random password
58+ // The generatePassword() function takes the user's selected criteria and generates a random password based on those criteria.
5359function generatePassword ( lower , upper , number , symbol , length ) {
5460 let generatedPassword = "" ;
5561 const typesCount = lower + upper + number + symbol ;
@@ -83,4 +89,4 @@ button.addEventListener("click", (e) => {
8389 false ,
8490 document . getElementById ( "PasswordResult" ) . select ( )
8591 ) ;
86- } ) ;
92+ } ) ;
0 commit comments