Skip to content

Comments

LON | Amirhossein Aminian | Module-structuring-and-testing-data | sprint3#142

Closed
AmirhosseinAminian wants to merge 38 commits intoCodeYourFuture:mainfrom
AmirhosseinAminian:amiraminia/sprint3
Closed

LON | Amirhossein Aminian | Module-structuring-and-testing-data | sprint3#142
AmirhosseinAminian wants to merge 38 commits intoCodeYourFuture:mainfrom
AmirhosseinAminian:amiraminia/sprint3

Conversation

@AmirhosseinAminian
Copy link

@AmirhosseinAminian AmirhosseinAminian commented Nov 14, 2024

Learners, PR Template

Self checklist

  • I have committed my files one by one, on purpose, and for a reason
  • I have titled my PR with COHORT_NAME | FIRST_NAME LAST_NAME | REPO_NAME | WEEK
  • I have tested my changes
  • My changes follow the style guide
  • My changes meet the requirements of this task

Changelist

Briefly explain your PR.

Questions

Ask any questions you have for your reviewer.

@AmirhosseinAminian AmirhosseinAminian added the Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. label Nov 14, 2024
Copy link
Member

@SallyMcGrath SallyMcGrath left a comment

Choose a reason for hiding this comment

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

@Amir200524 , why have you submitted Java in .js files?

@AmirhosseinAminian
Copy link
Author

Hi @SallyMcGrath. I am so sorry about it. I converted them to JavaScript. Thank you.

@AmirhosseinAminian AmirhosseinAminian added the Complete Volunteer to add when work is complete and all review comments have been addressed. label Nov 26, 2024
@SallyMcGrath
Copy link
Member

Hi @SallyMcGrath. I am so sorry about it. I converted them to JavaScript. Thank you.

Great, but can you talk a abit about what happened?

@AmirhosseinAminian
Copy link
Author

Hi @SallyMcGrath I was watching some videos on YouTube about Java, and I probably answered some of them in Java. It’s so weird because I didn’t realize that VS Code was showing me some errors.

Copy link
Contributor

@cjyuan cjyuan left a comment

Choose a reason for hiding this comment

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

It doesn't seem anyone had comment on your code yet and there is a "Review Needed" label, so I am jumping in.

Code is great and seems to work correctly. I just have a few comments about the test cases and some suggestions.

console.log(validateCreditCard("a92332119c011112")); // false (invalid characters)
console.log(validateCreditCard("4444444444444444")); // false (only one type of number)
console.log(validateCreditCard("1111111111111110")); // false (sum less than 16)
console.log(validateCreditCard("6666666666666661")); // false (odd final number) No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not check also cases where number of digits is not exactly 16?

// If the character is a letter (either uppercase or lowercase),
// it rotates the character by the specified shift value within the alphabet,
// considering wrapping around if necessary. Non-letter characters are returned unchanged.
function rotateCharacter(char, shift) {
Copy link
Contributor

Choose a reason for hiding this comment

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

How would you modify your implementation if shift is allowed to be a negative number to represent a rotation in the opposite direction?

console.log(rotateCharacter("z", 1)); // Output: "a" (preserves case, but wraps around)
console.log(rotateCharacter("Y", 2)); // Output: "A" (preserves case, but wraps around)
console.log(rotateCharacter("z", 1)); // Output: "a" (wraps around)
console.log(rotateCharacter("Y", 2)); // Output: "A" (wraps around)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not test cases where shift is a large integer (e.g., 100, -100)?

function isPrime(num) {
if (num <= 1) return false;

for (let i = 2; i <= Math.sqrt(num); i++) {
Copy link
Contributor

Choose a reason for hiding this comment

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

You can possibly improve the performance of the code in the following manners:

  • Check if num is 2, and check only odd numbers >= 3 in the loop
  • Avoid calling Math.sqrt(num) repeatedly by assigning the value of Math.sqrt(num) to a variable once, and then refer to the variable in the condition of the loop.
    • Note: The condition is checked at the start of every iteration.

}

// Sample list of previous passwords
const previousPasswords = ["password123", "abc123", "welcome1"];
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. You can also export previousPasswords.
  2. The passwords in previousPasswords are all invalid passwords.

});

test('returns false for a valid password format but already used', () => {
expect(isValidPassword('welcome1', previousPasswords)).toBe(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

The function could be returning false because "welcome1" does not have any uppercase letter. So this test may fail to check if the function can handle correctly cases where the password is already in used.

@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 Nov 29, 2024
@AmirhosseinAminian
Copy link
Author

Hi @cjyuan thank you for your valuable tips.

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

Labels

Complete Volunteer to add when work is complete and all review comments have been addressed. 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.

4 participants