-
Notifications
You must be signed in to change notification settings - Fork 0
/
StrongPassword.js
45 lines (33 loc) · 1.05 KB
/
StrongPassword.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
function minimumNumber(n, password) {
const numbers = "0123456789".split("")
const lower_case = "abcdefghijklmnopqrstuvwxyz".split("")
const upper_case = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("")
const special_characters = "!@#$%^&*()-+".split("")
let checkNum = false;
let checkLower = false;
let checkUpper = false;
let checkSpecial = false;
const arrPass = password.split("")
let count = 0;
lower_case.map((val) => arrPass.includes(val) ? checkLower = true : val)
upper_case.map((val) => arrPass.includes(val) ? checkUpper = true : val)
special_characters.map((val) => arrPass.includes(val) ? checkSpecial = true : val)
numbers.map((val) => arrPass.includes(val) ? checkNum = true : val)
if (!checkLower) {
count++
}
if (!checkUpper) {
count++
}
if (!checkSpecial) {
count++
}
if (!checkNum) {
count++
}
if (arrPass.length + count < 6) {
const len = 6 - (arrPass.length + count)
return count + len;
}
return count;
}