Birmingham | 26-ITP-May | Ogbemi Mene | Sprint 3 | Coursework with jest#1482
Birmingham | 26-ITP-May | Ogbemi Mene | Sprint 3 | Coursework with jest#1482meneogbemi42-bit wants to merge 9 commits into
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
f190c45 to
0f14126
Compare
LonMcGregor
left a comment
There was a problem hiding this comment.
Good start on this task, lots of good varied test cases. I've got a couple of comments about your implementations
| function isProperFraction(numerator, denominator) { | ||
| // TODO: Implement this function | ||
| // A denominator of 0 is mathematically undefined, so it cannot be a proper fraction. | ||
| if (denominator === 0) { |
There was a problem hiding this comment.
Could you combine this condition with the returned expression below?
There was a problem hiding this comment.
ok, that escape me iniatially. thanks for the observation
| // TODO: Implement this function | ||
| // Parse numeric ranks ("2" through "10") | ||
| const numericValue = parseInt(rank, 10); | ||
| if (!isNaN(numericValue) && numericValue >= 2 && numericValue <= 10 && String(numericValue) === rank) { |
There was a problem hiding this comment.
What does String(numericValue) === rank do here?
There was a problem hiding this comment.
String(numericValue) === rank acts as a crucial validation guard. It checks if the original rank string was perfectly converted into a number, with no extra characters, decimal points, or weird spacing hanging around.
|
Good explanation about the guard - I think it might be a bit unnecessary though, as you are converting to an integer immediately before you convert back to a string, so if there was a problem, it would show up there. However, it is good that you are considering these edge cases. Great job simplifying the return value in the fractions task. Now that your return has a zero check, do you still need the if earlier in the code? |
|
please i just wanted to be sure of the code you are talking about so i chould correct it. |
|
I think here you could probably remove the guard. You can also change your fractions function - now you have your zero checked in the return, do you still need the if part above it? |
Removed redundant check for string equality in numeric rank validation.
|
if i remove {if (rank === "A") return 11;} passing an Ace (like "A♠") will now be treated as an invalid rank and will throw an error. and If you remove the line if (["J", "Q", "K"].includes(rank)) return 10;, face cards (Jacks, Queens, and Kings) will no longer be recognized as valid and will throw an error. |
##Self checklist
Changelist
This PR implements the Sprint-3 exercise solutions and adds rewritten Jest tests — it implements three functions (getAngleType, isProperFraction, getCardValue), adds input validation/edge-case handling, and adds comprehensive Jest test suites for each.