We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 853d408 commit 93ae4e9Copy full SHA for 93ae4e9
Sprint-3/2-mandatory-rewrite/3-get-card-value.js
@@ -1,13 +1,13 @@
1
function getCardValue(card) {
2
const rank = card.slice(0, -1); // remove suit
3
4
- if (!rank) throw new Error("Invalid card rank");
+ if (!rank) throw new Error(`Invalid card rank: ${card}`);
5
6
if (rank === "A") return 11;
7
if (["K", "Q", "J"].includes(rank)) return 10;
8
if (/^(?:[2-9]|10)$/.test(rank)) return Number(rank);
9
10
- throw new Error("Invalid card rank");
+ throw new Error(`Invalid card rank: ${card}`);
11
}
12
13
module.exports = getCardValue;
0 commit comments