Skip to content

Commit 2fb1964

Browse files
authored
Update 3-get-card-value.js
1 parent f9a21a9 commit 2fb1964

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,23 @@ function getCardValue(card) {
3737
const rank = card.slice(0, -1);
3838
if (rank === "A") return 11;
3939
if (rank === "J" || rank === "Q" || rank === "K") return 10;
40+
}
41+
42+
if (
43+
rank === "2" ||
44+
rank === "3" ||
45+
rank === "4" ||
46+
rank === "5" ||
47+
rank === "6" ||
48+
rank === "7" ||
49+
rank === "8" ||
50+
rank === "9" ||
51+
rank === "10"
52+
) {
53+
return Number(rank);
54+
}
4055

41-
56+
throw new Error("Invalid card");
4257
}
4358

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

0 commit comments

Comments
 (0)