From 0d54957f925f0d4eabae8ef014791214bc41581c Mon Sep 17 00:00:00 2001 From: Kyle Silva Date: Thu, 9 Jul 2020 21:09:13 -0400 Subject: [PATCH] Password has passed all tests --- index.js | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index a72e7e6..81ed6aa 100644 --- a/index.js +++ b/index.js @@ -1 +1,42 @@ -// Do work! \ No newline at end of file + + +function validatePassword(password) { + let upperCaseCheck = false + let lowerCaseCheck = false + let numbersCheck = false + let specialCheck = false + + if (password.length >= 8) { //checking for password length if true to the following + // this for loop loops through each letter the password + for(let i = 0; i < password.length; i++){ + if (password.charAt(i) != password.charAt(i).toUpperCase()) { + upperCaseCheck = true + } + if (password.charAt(i) != password.charAt(i).toLowerCase()) { + lowerCaseCheck = true + } + if (/[~`!#$%\^&*+=\-\[\]\\';,/{}|\\":<>\?]/g.test(password.charAt(i))){ + specialCheck = true + } + if (!isNaN(password.charAt(i))) { + numbersCheck = true + } + + } + if (upperCaseCheck == true && lowerCaseCheck == true && specialCheck == true && numbersCheck == true) { + return true + + } else { + return false + } + } else { + return false + } + + + + +} + + +module.exports = validatePassword \ No newline at end of file