-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
26 lines (20 loc) · 736 Bytes
/
script.js
File metadata and controls
26 lines (20 loc) · 736 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const passwordBox = document.getElementById("password");
const genreateButton = document.getElementById("generate");
const lenght = 12;
const upeerCase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const lowerCase = "abcdefghijklmnopqrstuvwxyz";
const numbers = "0123456789";
const symbol = "!@#$%^&*()_+={}[]<>/,";
const allVal = upeerCase + lowerCase + numbers + symbol;
function generatePassowrd(){
let password = "";
while (lenght > password.length) {
password += allVal[Math.round(Math.random() * allVal.length)];
}
passwordBox.value = password;
}
function copyPassword() {
passwordBox.select();
navigator.clipboard.writeText(passwordBox.value);
}
genreateButton.addEventListener("click", generatePassowrd);