Skip to content

Commit 0b3f72a

Browse files
committed
used Es6 format
1 parent 42fa2b2 commit 0b3f72a

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

Source-Code/PasswordGenerator/script.js

+7-13
Original file line numberDiff line numberDiff line change
@@ -24,30 +24,24 @@ clipboardEl.addEventListener('click', () => {
2424
alert('Password copied to clipboard!');
2525
});
2626

27-
function getRandomLower() {
28-
return String.fromCharCode(Math.floor(Math.random() * 26) + 97);
29-
}
27+
const getRandomLower = () => String.fromCharCode(Math.floor(Math.random() * 26) + 97);
3028

31-
function getRandomUpper() {
32-
return String.fromCharCode(Math.floor(Math.random() * 26) + 65);
33-
}
29+
const getRandomUpper = () => String.fromCharCode(Math.floor(Math.random() * 26) + 65);
3430

35-
function getRandomNumber() {
36-
return String.fromCharCode(Math.floor(Math.random() * 10) + 48);
37-
}
31+
const getRandomNumber = () => String.fromCharCode(Math.floor(Math.random() * 10) + 48);
3832

39-
function getRandomSymbol() {
33+
const getRandomSymbol = () => {
4034
const symbols = '!@#$%^&*(){}[]=<>/,.';
4135
return symbols[Math.floor(Math.random() * symbols.length)];
42-
}
36+
};
4337

4438
const randomFunc = {
4539
lower: getRandomLower,
4640
upper: getRandomUpper,
4741
number: getRandomNumber,
4842
symbol: getRandomSymbol,
4943
};
50-
function generatePassword(lower, upper, number, symbol, length) {
44+
const generatePassword = (lower, upper, number, symbol, length) => {
5145
let generatedPassword = '';
5246
const typesCount = lower + upper + number + symbol;
5347
const typesArr = [{ lower }, { upper }, { number }, { symbol }].filter(
@@ -68,7 +62,7 @@ function generatePassword(lower, upper, number, symbol, length) {
6862
const finalPassword = generatedPassword.slice(0, length);
6963

7064
return finalPassword;
71-
}
65+
};
7266
generateEl.addEventListener('click', () => {
7367
const length = +lengthEl.value;
7468
const hasLower = lowercaseEl.checked;

0 commit comments

Comments
 (0)