Skip to content
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

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

Open
wants to merge 38 commits into
base: main
Choose a base branch
from

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 Participant to add when requesting review 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?

@SallyMcGrath SallyMcGrath added the Nothing submitted Either nothing has been submitted at all, or nothing reviewable label Nov 21, 2024
@AmirhosseinAminian
Copy link
Author

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

@AmirhosseinAminian AmirhosseinAminian removed the Nothing submitted Either nothing has been submitted at all, or nothing reviewable label Nov 21, 2024
@AmirhosseinAminian AmirhosseinAminian added the Complete Participant to add when work is complete and 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

@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)
Copy link

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

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

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

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

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

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 and removed Needs Review Participant to add when requesting review 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 Participant to add when work is complete and review comments have been addressed Reviewed Volunteer to add when completing a review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants