Skip to content

WM | May-2025 | Abdullah Saleh | Sprint-3 #627

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

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

Conversation

3bdullah-saleh
Copy link

@3bdullah-saleh 3bdullah-saleh commented Jun 30, 2025

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 REGION | COHORT_NAME | FIRST_NAME LAST_NAME | PROJ_NAME
  • 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.

@3bdullah-saleh 3bdullah-saleh added the Needs Review Participant to add when requesting review label Jun 30, 2025
@3bdullah-saleh 3bdullah-saleh changed the base branch from coursework/sprint-3 to main June 30, 2025 11:06
Copy link

@sathudeva7 sathudeva7 left a comment

Choose a reason for hiding this comment

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

Always validate input types (string/number) when writing functions that expect numbers.

function isProperFraction(numerator, denominator) {
    if (denominator === 0) return "Undefined";
    else if (numerator < denominator) return true;
    else return false;
}
``` check the type of input variable

@illicitonion illicitonion added Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. and removed Needs Review Participant to add when requesting review labels Jul 16, 2025
Copy link
Member

@illicitonion illicitonion left a comment

Choose a reason for hiding this comment

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

This is generally looking really good, but I left a few comments of things to think about.

I haven't reviewed the card validator yet, I'll take a look later today, but wanted to leave you some comments you can work on in the mean time!

@illicitonion illicitonion added Reviewed Volunteer to add when completing a review and removed Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Jul 16, 2025
Copy link
Member

@illicitonion illicitonion left a comment

Choose a reason for hiding this comment

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

Your card number validator is looking good too, though I left a few comments to consider as well! I'm glad you attempted it, doing the stretch work is really useful for learning!

Comment on lines +2 to +5
if (cardNumber.length !== 16) {
return false;
}
const numberInArray = cardNumber.toString().split(""); // convert the cardNumber to sting then into an array
Copy link
Member

Choose a reason for hiding this comment

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

It's interesting that you check its length and then convert it to a string. What type do you think cardNumber may have which has a .length property, but isn't a string?

Copy link
Author

Choose a reason for hiding this comment

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

I originally thought this was an edge case to handle, but it turned out not to be a good approach — even my test tricked me by passing.

The reason the test passed is because cardNumber.length was undefined, so the condition undefined !== 16 returned true, leading to a false return value that matched the expected outcome.

I later got advice from AI that JavaScript rounds numbers longer than 15 digits, so it's always better to pass long numbers like card numbers as strings.

Just to confirm — I’m planning to remove the .toString() call from my function, since the cardNumber will always be passed as a string.

Copy link
Member

@illicitonion illicitonion left a comment

Choose a reason for hiding this comment

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

This is all looking good - I'll mark this as Complete, but I've left a couple of interesting questions to ponder :)

function repeat(str, count) {
if (count > 0) return `${str.repeat(count)}`;
else if (count == 0) return "";
else if (count < 0) return "negative counts are not valid";
Copy link
Member

Choose a reason for hiding this comment

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

What do you think about returning a string here vs throwing an error? With the fraction with denominator of 0 you decided to throw - is there a reason to prefer one or the other here?

Copy link
Author

Choose a reason for hiding this comment

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

You're right — there's no strong reason for treating them differently.
It would be more consistent to throw an error for invalid input like a negative count, just as I did with the zero denominator case.

Comment on lines +4 to +5
else if (rank >= 2 && rank <= 9) return Number(rank);
else if (rank === 10 || rank === "J" || rank === "Q" || rank === "K") return 10;
Copy link
Member

Choose a reason for hiding this comment

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

You could have handled 10 in the "If a number" case or the "J/Q/K" case (both of which work). Why did you decide to choose the approach you did? What benefits/drawbacks does each have?

Copy link
Author

Choose a reason for hiding this comment

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

Actually, I handled it that way because I was following the structure of the test cases. I assumed that 10 could be treated as part of the numeric range and added to the first condition, rather than grouping it with the string values like "J", "Q", or "K".

@illicitonion illicitonion added Complete Volunteer to add when work is complete and review comments have been addressed and removed Reviewed Volunteer to add when completing a review labels Jul 17, 2025
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 review comments have been addressed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants