-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpassword.js
47 lines (32 loc) · 1.04 KB
/
password.js
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
const characters = [...Array(95).keys()].map(i => String.fromCharCode(i+32));
let password1 = '' ;
let password2 = '';
let password3 = '';
let password4 = '';
let random, num, pass1El, pass2El, pass3El, pass4El;
function randomPass() {
num = Math.floor(Math.random() * characters.length)
random = characters[num]
return random
}
for( var i = 0; i < 15; i++) {
password1 += randomPass();
password2 += randomPass();
password3 += randomPass();
password4 += randomPass();
}
function displayPass() {
pass1El = document.getElementById('password1');
pass2El = document.getElementById('password2');
pass3El = document.getElementById('password3');
pass4El = document.getElementById('password4');
pass1El.textContent = password1;
pass2El.textContent = password2;
pass3El.textContent = password3;
pass4El.textContent = password4;
}
const btnEl = document.getElementById("btn-el")
btnEl.addEventListener("click", function(){
randomPass()
displayPass()
})