Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HOMEWORK 1 #9

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 29 additions & 3 deletions session-01/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,43 @@
- username cannot contain special characters
*/
function validUsername(username) {
return;
}
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;
}

return true
};

/*
Write a function that returns true or false if the given password
is valid according to the following rules:
- 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;
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;
}


module.exports = { validUsername, validPassword };
10 changes: 10 additions & 0 deletions session-02/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/
function transformArrayToUpper(listOfStrings) {
return;
return listOfStrings.map(str => str.toUpperCase());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the return on line 6 and 20 are causing your test fails

}

/*
Expand All @@ -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 };
Loading