Skip to content

London | 26-ITP-May | Tomislav Dukez | Sprint 3 | Stretch#1454

Open
tomdu3 wants to merge 13 commits into
CodeYourFuture:mainfrom
tomdu3:coursework/sprint-3/4-stretch
Open

London | 26-ITP-May | Tomislav Dukez | Sprint 3 | Stretch#1454
tomdu3 wants to merge 13 commits into
CodeYourFuture:mainfrom
tomdu3:coursework/sprint-3/4-stretch

Conversation

@tomdu3

@tomdu3 tomdu3 commented Jul 3, 2026

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

Changelist

Added tasks:

  1. find
  2. password validator
  3. card validator

@github-actions

This comment has been minimized.

@tomdu3 tomdu3 added 🏝️ Priority Stretch Do this once mandatory work is done Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Module-Structuring-And-Testing-Data The name of the module. labels Jul 3, 2026
@tomdu3 tomdu3 changed the title London | 26-ITP-May | Tomislav Dukez | Sprint 3 | Strech London | 26-ITP-May | Tomislav Dukez | Sprint 3 | Stretch Jul 3, 2026
@github-actions

This comment has been minimized.

@github-actions github-actions Bot removed the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Jul 3, 2026
@tomdu3 tomdu3 added 📅 Sprint 3 Assigned during Sprint 3 of this module Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Jul 3, 2026
Comment on lines +2 to +5
// Check if the card number is a positive integer.
if (typeof cardNumber !== "number" || cardNumber < 0) {
return 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.

Note:

  • To check if a value is in integer, Number.isInteger() is better.

  • Credit card numbers typically have 16 digits, but not all 16-digit integers can be safely represented as a number in JS -- many numbers larger than Number.MAX_SAFE_INTEGER cannot be represented properly. For example, 9007199254740993. Normally, card numbers are represented as strings.

No change required.

Comment on lines +26 to +28
// In case of the call find("code your future", "z"), the index variable updates as follows:
// 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 - when it stops, because the condition index < str.length is no longer true
// the and because the loop has arrived to the end of the string without finding "z".

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.

In case of the call find("code your future", "z"), the index variable updates as follows:

The last value of index in this function call is not 14.

- Have at least one of the following non-alphanumeric symbols: ("!", "#", "$", "%", ".", "*", "&")
- Must not be any previous password in the passwords array.
*/
const passwords = ["pa$$w0rd", "Qwerty1#", "Adm1n2#", "$3cr4t"];

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 consider design the function to accept the "used passwords" through an optional parameter with default value.

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.

Thanks. That actually gives a more elegant solution.

!/[A-Z]/.test(password) ||
!/[a-z]/.test(password) ||
!/[0-9]/.test(password) ||
!/[!#\$%\.\*&]/.test(password) ||

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.

Some of the characters in the [...] on line 16 do not need to be escaped.

Could you look this up?

Inside [...] of a regular expression in JS, which characters need to be escaped?

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.

Thank you CJ. I am only confused with the regex characters here. I was convinced $, . and * needed to be escaped, because otherwise they would considered as special regex chars. But thanks.

Comment on lines +54 to +61
test("password has at least one English lowercase letter (a-z)", () => {
// Arrange
const password = "1234Aa%";
// Act
const result = isValidPassword(password);
// Assert
expect(result).toEqual(true);
});

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.

Note:

  • One check for valid case is probably enough. Besides, having a lowercase letter (or digit, etc.) does not necessary make a password valid.

  • Your tests for invalid cases are comprehensive. Well done.

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.

awesome, thanks.

@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 Jul 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Module-Structuring-And-Testing-Data The name of the module. 🏝️ Priority Stretch Do this once mandatory work is done Reviewed Volunteer to add when completing a review with trainee action still to take. 📅 Sprint 3 Assigned during Sprint 3 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants