Skip to content

Commit 035e27e

Browse files
committed
removed check for ace of spades, adjusted rank to give the full value for cards with more than 1 digit, removed check for negative value since im using maths.abs
1 parent 2765c49 commit 035e27e

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

Sprint-3/1-implement-and-rewrite-tests/implement/2-is-proper-fraction.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,14 @@
88
// write one test at a time, and make it pass, build your solution up methodically
99

1010
function isProperFraction(numerator, denominator) {
11-
if (Math.sign(numerator) === -1 || Math.sign(denominator) === -1) {
12-
if (Math.abs(numerator) < Math.abs(denominator)) {
13-
return true;
14-
}
15-
} else if (numerator === 0) {
16-
return false;
17-
}
18-
19-
if (numerator < denominator) {
11+
if (Math.abs(numerator) < Math.abs(denominator)) {
2012
return true;
2113
} else if (numerator > denominator) {
2214
return false;
2315
} else if (numerator === denominator) {
2416
return false;
17+
} else if (numerator === 0) {
18+
return false;
2519
}
2620
}
2721

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@
88
// write one test at a time, and make it pass, build your solution up methodically
99
// just make one change at a time -- don't rush -- programmers are deep and careful thinkers
1010
function getCardValue(card) {
11-
const rank = card[0];
11+
let rank = "";
1212

13-
if (card === "A♠") {
14-
return 11;
15-
} else if (Number(rank) > 1 && Number(rank) < 10) {
13+
for (let i = 0; i < card.length - 1; i++) {
14+
rank += card[i];
15+
}
16+
17+
if (Number.isInteger(Number(rank)) && Number(rank) > 1 && Number(rank) < 10) {
1618
return Number(rank);
1719
} else if (rank === "10" || rank === "J" || rank === "Q" || rank === "K") {
1820
return 10;
@@ -68,5 +70,5 @@ assertEquals(ace, 11);
6870
// Given a card with an invalid rank (neither a number nor a recognized face card),
6971
// When the function is called with such a card,
7072
// Then it should throw an error indicating "Invalid card rank."
71-
const invalidCard = getCardValue("15♠");
73+
const invalidCard = getCardValue("100♠");
7274
assertEquals(invalidCard, "Invalid card rank.");

0 commit comments

Comments
 (0)