Skip to content

Commit abdf3d1

Browse files
committed
Password validator
1 parent eee0dce commit abdf3d1

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
const passwordValidation = (password) => {
2+
let hasLowerCase = false;
3+
let hasUpperCase = false;
4+
let hasDigit = false;
5+
if (password.length < 8) {
6+
return false;
7+
}
8+
for (let char of password) {
9+
if (char.charCodeAt(0) >= 65 && char.charCodeAt(0) <= 97) {
10+
hasLowerCase = true;
11+
} else if (char.charCodeAt(0) >= 97 && char.charCodeAt(0) <= 122) {
12+
hasUpperCase = true;
13+
} else if(!isNaN(Number(char))){
14+
hasDigit = true;
15+
}
16+
}
17+
if (!hasLowerCase || !hasUpperCase || !hasDigit) {
18+
return false;
19+
}
20+
return true;
21+
};
22+
23+
24+
25+
console.log(passwordValidation("asdksajaAs"));

0 commit comments

Comments
 (0)