Skip to content

Commit cdffcf7

Browse files
Update script.js
added some more detailed comments
1 parent 37a8192 commit cdffcf7

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

script.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,30 @@ Math.floor() function returns the largest integer less than or equal to a given
55
For generating a random uppercase lowercase text random numbers symbols we use Charcode
66
http://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.
810
function 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.
1215
function 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.
1620
function 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.
2025
function 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.
2632
const 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.
5359
function 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

Comments
 (0)