From eac2589b3535047e687225422ae58d13e79f472b Mon Sep 17 00:00:00 2001 From: kjara03 Date: Sun, 4 Aug 2024 16:05:25 -0400 Subject: [PATCH 1/3] Update validators.js --- session-01/validators.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/session-01/validators.js b/session-01/validators.js index 56ea66d..ae26ced 100644 --- a/session-01/validators.js +++ b/session-01/validators.js @@ -8,8 +8,19 @@ */ function validUsername(username) { return; + if (username.length >= 3 && username.length <= 10 && /^[a-zA-Z]/.test(username) && /^[a-zA-Z0-9]+$/.test(username)) + return true; + else + return false; } + console.log(isValidUsername("ab12")); //true + console.log(isValidUsername("ab")); // false + console.log(isValidUsername("12bc")); // false + console.log(isValidUsername("ab!12")); // false + console.log(isValidUsername("abcdef")); // false + + /* Write a function that returns true or false if the given password is valid according to the following rules: @@ -18,6 +29,12 @@ function validUsername(username) { */ function validPassword(password) { return; + function validPassword(password) { + return /[a-zA-Z]/.test(password) && /\d/.test(password) && /[!@#$%^&*(),.?":{}|<>]/.test(password) && password.length >= 10 && password.length <= 64; + } } +console.log(validPassword(password1!)); //true +console.log(validPassword(pass1word)); //false + module.exports = { validUsername, validPassword }; From f5f2692261ea3aad5dd185007a75c69e32a9c58a Mon Sep 17 00:00:00 2001 From: kjarapepushaj <161673112+kjarapepushaj@users.noreply.github.com> Date: Mon, 5 Aug 2024 00:00:58 -0400 Subject: [PATCH 2/3] Update validators.js --- session-01/validators.js | 43 ++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/session-01/validators.js b/session-01/validators.js index ae26ced..cd20dcf 100644 --- a/session-01/validators.js +++ b/session-01/validators.js @@ -7,19 +7,20 @@ - username cannot contain special characters */ function validUsername(username) { - return; - if (username.length >= 3 && username.length <= 10 && /^[a-zA-Z]/.test(username) && /^[a-zA-Z0-9]+$/.test(username)) - return true; - else - return false; -} + if (username.length < 3 || username.length > 10) { + return false; + } + + if (!/^[a-zA-Z]/.test(username)) { + return false; + } + + if (!/^[a-zA-Z0-9]+$/.test(username)) { + return false; + } - console.log(isValidUsername("ab12")); //true - console.log(isValidUsername("ab")); // false - console.log(isValidUsername("12bc")); // false - console.log(isValidUsername("ab!12")); // false - console.log(isValidUsername("abcdef")); // false - + return true +}; /* Write a function that returns true or false if the given password @@ -27,14 +28,22 @@ function validUsername(username) { - password must be between (and including) 10-64 characters in length - password must contain at least 1 letter, 1 number, and 1 special character */ + function validPassword(password) { - return; - function validPassword(password) { - return /[a-zA-Z]/.test(password) && /\d/.test(password) && /[!@#$%^&*(),.?":{}|<>]/.test(password) && password.length >= 10 && password.length <= 64; + if (password.length < 10 || password.length > 64) { + return false; + } + if (!/[a-zA-Z]/.test(password)) { + return false; + } + if (!/\d/.test(password)) { + return false; + } + if (!/[!@#$%^&*(),.?":{}|<>]/.test(password)) { + return false; } + return true; } -console.log(validPassword(password1!)); //true -console.log(validPassword(pass1word)); //false module.exports = { validUsername, validPassword }; From 3be8c4356cbecd927d3faf2a73800a4dba183e1e Mon Sep 17 00:00:00 2001 From: kjara03 Date: Tue, 13 Aug 2024 21:40:35 -0400 Subject: [PATCH 3/3] Update exercise.js --- session-02/exercise.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/session-02/exercise.js b/session-02/exercise.js index 6ade818..3c79ebf 100644 --- a/session-02/exercise.js +++ b/session-02/exercise.js @@ -4,6 +4,7 @@ */ function transformArrayToUpper(listOfStrings) { return; + return listOfStrings.map(str => str.toUpperCase()); } /* @@ -17,6 +18,15 @@ function transformArrayToUpper(listOfStrings) { */ function sumOfAllAges(listOfStudentObjects) { return; + let totalAge = 0; + + for (let i = 0; i < listOfStudentObjects.length; i++) { + if (listOfStudentObjects[i].age) { + totalAge += listOfStudentObjects[i].age; + } + } + + return totalAge; } module.exports = { transformArrayToUpper, sumOfAllAges };