Birmingham | ITP-Jan-26 | Ayodeji Ayorinde | Sprint 3| 1-implement-and-rewrite-tests#1215
Birmingham | ITP-Jan-26 | Ayodeji Ayorinde | Sprint 3| 1-implement-and-rewrite-tests#1215Ayogit1 wants to merge 3 commits intoCodeYourFuture:mainfrom
Conversation
This comment has been minimized.
This comment has been minimized.
| function getCardValue(card) { | ||
| // TODO: Implement this function | ||
| rankCard = card.slice(0, 1); | ||
| if (rankCard === "A") { | ||
| return 11; | ||
| } else if (rankCard === "J" || rankCard === "Q" || rankCard === "K") { | ||
| return 10; | ||
| } else if (+rankCard >= 2 && +rankCard <= 10) { | ||
| return +rankCard; | ||
| } else { | ||
| return rankCard.toThrow(); | ||
| } | ||
| } |
There was a problem hiding this comment.
-
The function is expected to also validate if the last character is a valid suit character.
-
In JavaScript, strings that represent valid numeric literals in the language can be safely converted to equivalent numbers. For examples, "0x02", "2.1", or "0002".
Does your function return the value you expected from each of the following function calls?
getCardValue("0x02♠");
getCardValue("2.1♠");
getCardValue("0002♠");
| test(`should return "Invalid angle" when (angle > 360)`, () => { | ||
| // Test various acute angles, including boundary cases | ||
| expect(getAngleType(90)).toEqual("Invalid angle"); | ||
| }); No newline at end of file |
There was a problem hiding this comment.
-
The condition about invalid angle is not quite correct.
-
Can your function pass this test?
| test(`should return false when denominator is zero`, () => { | ||
| expect(isProperFraction(1, 7)).toEqual(false); | ||
| }); | ||
|
|
||
| // Special case: negatives | ||
| test(`should return false when denominator is zero`, () => { | ||
| expect(isProperFraction(1, -7)).toEqual(false); | ||
| }); |
There was a problem hiding this comment.
The description of the tests do not match the tests being carried out.
| // Number Cards (2-10) | ||
|
|
||
| test("Should return 2–10 for their respective card values", () => { | ||
| const cards = ["2", "3", "4", "5", "6", "7", "8", "9", "10"]; |
There was a problem hiding this comment.
A valid card should also have a valid suit character.
For example, "2♥". "2" should be considered an invalid card.
| expect(getCardValue(card)).toEqual(Number("Invalid")); | ||
|
|
||
| }); | ||
| }); |
There was a problem hiding this comment.
-
Test descriptions do not match the tests being carried out.
-
The function is expected to throw an error when the given card is invalid.
- Suggestion: Lookup how to throw error in JS, and follow the links line 44 to find out how to check if a function can throw an errors as expected in Jest.
| if (numerator < denominator) { | ||
| return "true"; | ||
| } else { | ||
| return "false"; | ||
| } |
There was a problem hiding this comment.
Can you lookup if -1/-2, 1/-2, -1/2, -1/0 are considered proper fractions, and then update
your implementation and tests accordingly?
Learners, PR Template
Self checklist
Changelist
Completion of 1-implement-and-rewrite-tests tasks