Skip to content

Commit ed2ba1a

Browse files
committed
changes are made in 2 files
1 parent 1c5754b commit ed2ba1a

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed

Sprint-3/1-implement-and-rewrite-tests/implement/2-is-proper-fraction.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
function isProperFraction(numerator, denominator) {
1111
// Case 1 & general case: numerator < denominator
12-
if (Math.abs(numerator) < denominator) {
12+
if (Math.abs(numerator) < Math.abs(denominator)) {
1313
return true;
1414
} else {
1515
return false;

Sprint-3/1-implement-and-rewrite-tests/implement/3-get-card-value.js

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,32 @@ function getCardValue(card) {
2222
return 10;
2323
}
2424

25-
// Handle number cards 2-9
26-
const num = Number(rank);
27-
if (num >= 2 && num <= 9) {
28-
return num;
25+
// Handle number cards 2-10
26+
const validRanks = [
27+
"A",
28+
"2",
29+
"3",
30+
"4",
31+
"5",
32+
"6",
33+
"7",
34+
"8",
35+
"9",
36+
"10",
37+
"J",
38+
"Q",
39+
"K",
40+
];
41+
42+
// Check if rank is valid
43+
if (!validRanks.includes(rank)) {
44+
throw new Error("Invalid card rank.");
2945
}
3046

31-
// Invalid card
32-
throw new Error("Invalid card rank.");
47+
// Return correct values
48+
if (rank === "A") return 11;
49+
if (["J", "Q", "K"].includes(rank)) return 10;
50+
return Number(rank); // for 2–10
3351
}
3452

3553
// The line below allows us to load the getCardValue function into tests in other files.

0 commit comments

Comments
 (0)