Skip to content

London | 26-ITP-May | Russom Gebremeskel | Sprint 3 | Coursework Stretch - #1746

Open
russom-g wants to merge 75 commits into
CodeYourFuture:mainfrom
russom-g:coursework/sprint-3-stretch
Open

russom-g wants to merge 75 commits into
CodeYourFuture:mainfrom
russom-g:coursework/sprint-3-stretch

Conversation

@russom-g

Copy link
Copy Markdown

Learners, PR Template

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Task code

CYF-1065

Changelist

Password validator test written and function implemented. Questions answers and code explained

@github-actions

This comment has been minimized.

@russom-g russom-g added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Oct 22, 2026

@cjyuan cjyuan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why not also try the card-validator exercise?

Comment on lines +9 to +14
for (const char of password) {
if (!/[A-Z]/.test(password)) return false;
if (!/[a-z]/.test(password)) return false;
if (!/[0-9]/.test(password)) return false;
if (!/[!#$%.*&]/.test(password)) return false;
}

@cjyuan cjyuan Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Where is char (the loop variable) being used?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

It's a dead code that I forgot to delete from previous attempt to solve the problesm.

Comment on lines +56 to +61
test("password must not be any previous password in the passwords array", () => {
const password = "1Az9!";
const previousPassword = ["1Az9!", "1HBz2!"];
const result = isValidPassword(password, previousPassword);
expect(result).toEqual(false);
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could the function return true if the valid password is not one of the previous passwords?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yes. I changed the test to (true) and it fails.

// b) What is the if statement used to check
// - It checks whether the character at position index of str is exactly equal to char. If so it returns that position.
// c) Why is index++ being used?
// - index++ checks the next character of str. Without index would stay at 0 and the loop would never stop.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

index++ does not "check the next character str". Could you rephrase the statement?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

index++ increments by 1 each time the lope find a match?

@cjyuan cjyuan Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

That still does not quite explain "why" it is being used in the code.

@cjyuan cjyuan added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Oct 24, 2026
@russom-g

Copy link
Copy Markdown
Author

@cjyuan I didn't know there was another card-validator exercise. I will do it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Reviewed Volunteer to add when completing a review with trainee action still to take.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants