Skip to content

Commit 5fb7cfb

Browse files
author
russom
committed
If statement for checking invalid card implemented
1 parent f4ea51e commit 5fb7cfb

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@
2323

2424
function getCardValue(card) {
2525
// TODO: Implement this function
26+
if (card <= 1 && card >= 10 || typeof card !== "string") {
27+
// Here the type of values are checked whether they are string.
28+
return card + " Invalid card";
29+
}
2630

2731
const validRanks = [ // An array of ranks are created here
2832
"A",
@@ -40,10 +44,6 @@ function getCardValue(card) {
4044
"K",
4145
];
4246
const validSuits = ["♠", "♥", "♦", "♣"]; // An array of suits are created here.
43-
44-
if (typeof card !== "string") { // Here the type of values are checked whether they are string.
45-
return card + " Invalid card";
46-
}
4747
const suit = card.slice(-1);
4848
const rank = card.slice(0, -1);
4949

0 commit comments

Comments
 (0)