-
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?
Conversation
@DDiggs0798 we will want to approve reviews before closing to differentiate why something is closed. We should also always add a comment about why a review is closed if it not approved so it can be clear to the student and also any TAs that will see it later. |
/* eslint-disable nonblock-statement-body-position */ |
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?
index.js
Outdated
// Using ASCII index and charCodeAt method (thanks to Jkearns!) | ||
// Test further requirements | ||
// Test for uppercase characters |
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.
Given a password of 10 chars, we will loop 10 times from this outer loop.
Ya my bad I realized after I did a few that I forgot to leave reviews. I
know for next time now.
…On Thu, Jul 9, 2020 at 12:56 AM John Rice ***@***.***> wrote:
@DDiggs0798 <https://github.com/DDiggs0798> we will want to approve
reviews before closing to differentiate why something is closed.
We should also always add a comment about why a review is closed if it not
approved so it can be clear to the student and also any TAs that will see
it later.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#14 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ANGDEETVMHTWHH7JEQJ3ARTR2VEWFANCNFSM4OTOJEKA>
.
|
index.js
Outdated
for (let i = 0; i < password.length; i++) { | ||
if (password.charCodeAt(i) >= 97 && password.charCodeAt(i) <= 122) | ||
// Test for numeric value |
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.
Given a password of 10 chars, we will loop 10 times x 10 x 10 in this deeply nested inner loop.
We are now looping 1000 times. We are looping the same loop within itself.
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.
Nice work. Too much looping is occurring as noted in the review comments. We can get this down to a single for
loop.
index.js
Outdated
if (password.charCodeAt(i) >= 48 && password.charCodeAt(i) <= 57) | ||
// Test for special characters | ||
for (let i = 0; i < password.length; i++) { |
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.
Given a password of 10 chars, we will loop 10 times x 10 x 10 x 10 in this most deeply nested inner loop.
We are now looping 10,000 times. We are looping the same loop within itself.
Way more looping than needed. We can fix this so it loops only in the outer loop. 10x is all that the loop should need to run. There is an extra 9,990 loops happening here.
Erick and I did not work together. Hopefully he didn't end up looping as
much as I did lol! Are the extra loops occurring because of each additional
"for" loop i set up for each requirement test?
…On Thu, Jul 9, 2020 at 12:59 AM John Rice ***@***.***> wrote:
***@***.**** requested changes on this pull request.
Nice work. Too much looping is occurring as noted in the review comments.
We can get this down to a single for loop.
------------------------------
In index.js
<#14 (comment)>
:
> +
+ // 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
+ 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++) {
Given a password of 10 chars, we will loop 10 times x 10 x 10 x 10 in this
most deeply nested inner loop.
We are now looping 10,000 times. We are looping the same loop within
itself.
Way more looping than needed. We can fix this so it loops only in the
outer loop. 10x is all that the loop should need to run. There is an extra
9,990 loops happening here.
—
You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub
<#14 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/APY56KCIHFDP7JVHICJN7HDR2VFDPANCNFSM4OTOJEKA>
.
|
/* eslint-disable nonblock-statement-body-position */ | ||
function validatePassword(password) { |
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.
Formatting is a bit tough to read.
In VS Code, you can use the formatter. Menu > View > Command Palette. Type in "Format document"
function validatePassword(password) {
let requirementsMet = true
// Determine if the password length is more than or equal to 8 then..
if (password.length >= 8) {
requirementsMet = true
// Using ASCII index and charCodeAt method (thanks to Jkearns!)
} else {
requirementsMet = false
}
// Test further requirements
// Test for uppercase characters
for (let i = 0; i < password.length; i++) {
if (password.charCodeAt(i) >= 65 && password.charCodeAt(i) <= 90) {
requirementsMet = true
// Test for lowercase characters
} else {
requirementsMet = false
}
if (password.charCodeAt(i) >= 97 && password.charCodeAt(i) <= 122) {
requirementsMet = true
// Test for numeric value
} else {
requirementsMet = false
}
if (password.charCodeAt(i) >= 48 && password.charCodeAt(i) <= 57) {
requirementsMet = true
// Test for special characters
} else {
requirementsMet = false
}
if (password.charCodeAt(i) >= 33 && password.charCodeAt(i) <= 47) {
requirementsMet = true
} else {
requirementsMet = false
}
requirementsMet = true
requirementsMet = false
}
return requirementsMet
}
module.exports = validatePassword
No description provided.