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 599d6db commit 6a29885Copy full SHA for 6a29885
1 file changed
Sprint-3/1-implement-and-rewrite-tests/implement/3-get-card-value.js
@@ -71,5 +71,19 @@ try {
71
} catch (e) {}
72
73
// What other invalid card cases can you think of?
74
-assertEquals(getCardValue("♦♦"), "invalid"); // throws an error for this example
75
-assertEquals(getCardValue("12"), "Error");
+// Handling invalid cards
+function assertThrows(testFunction) {
76
+ let threw = false;
77
+
78
+ try {
79
+ testFunction();
80
+ } catch (error) {
81
+ threw = true;
82
+ }
83
84
+ console.assert(threw, "Expected function to throw an error.")
85
+}
86
87
+assertThrows(() => getCardValue("1♣"));
88
+assertThrows(() => getCardValue("12"));
89
+assertThrows(() => getCardValue("♦3"));
0 commit comments