-
Notifications
You must be signed in to change notification settings - Fork 18
Pass all tests except for the special character requirement test #14
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
base: master
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,31 @@ | ||
| // Do work! | ||
| /* eslint-disable nonblock-statement-body-position */ | ||
| function validatePassword(password) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Formatting is a bit tough to read. In VS Code, you can use the formatter. Menu > View > Command Palette. Type in "Format document" |
||
| let allRequirementsMet = false | ||
| let specCharacters = '!"#$%&/' / '()*+,-.' | ||
|
|
||
| // Determine if the password length is more than or equal to 8 then.. | ||
| if (password.length >= 8) { | ||
| // Using ASCII index and charCodeAt method (thanks to Jkearns!) | ||
| // Test further requirements | ||
| // Test for uppercase characters | ||
|
||
| for (let i = 0; i < password.length; i++) { | ||
| if (password.charCodeAt(i) >= 65 && password.charCodeAt(i) <= 90) | ||
| // Test for lowercase characters | ||
johnny-rice marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| for (let i = 0; i < password.length; i++) { | ||
| if (password.charCodeAt(i) >= 97 && password.charCodeAt(i) <= 122) | ||
| // Test for numeric value | ||
|
||
| for (let i = 0; i < password.length; i++) { | ||
| if (password.charCodeAt(i) >= 48 && password.charCodeAt(i) <= 57) | ||
| // Test for special characters | ||
| for (let i = 0; i < password.length; i++) { | ||
|
||
| if (password.charCodeAt(i) >= 33 && password.charCodeAt(i) <= 46) | ||
| allRequirementsMet = true | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return allRequirementsMet | ||
| } | ||
| module.exports = validatePassword | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This solution is very close to the solution @erick-pacheco has. Did you guys work together on this work?