Skip to content

Commit 9a2b257

Browse files
committed
restored file
1 parent 649d804 commit 9a2b257

File tree

1 file changed

+7
-16
lines changed

1 file changed

+7
-16
lines changed

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

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@
2222
// execute the code to ensure all tests pass.
2323

2424
function getCardValue(card) {
25-
26-
}
27-
25+
// TODO: Implement this function
26+
}
2827

2928
// The line below allows us to load the getCardValue function into tests in other files.
3029
// This will be useful in the "rewrite tests with jest" step.
@@ -39,23 +38,15 @@ function assertEquals(actualOutput, targetOutput) {
3938
}
4039

4140
// TODO: Write tests to cover all outcomes, including throwing errors for invalid cards.
42-
// Examples 1 numbers:
41+
// Examples:
4342
assertEquals(getCardValue("9♠"), 9);
4443

45-
46-
function assertThrow(fn){
47-
try { (fn)
48-
// we try to run this function, if it throws, stop running this bit and run the catch below
44+
// Handling invalid cards
45+
try {
46+
getCardValue("invalid");
4947

5048
// This line will not be reached if an error is thrown as expected
5149
console.error("Error was not thrown for invalid card");
52-
} catch (error) {
53-
// if the above code throws, we catch the error here, that stops the whole program crashing
54-
55-
50+
} catch (e) {}
5651

5752
// What other invalid card cases can you think of?
58-
59-
//Examples wrong type:
60-
assertThrow(()=>getCardValue("null"))
61-
assertThrow(()=>getCardValue("42"))

0 commit comments

Comments
 (0)