Skip to content

Commit de32580

Browse files
committed
completed few tasks of Sprint 3
1 parent 3372770 commit de32580

File tree

4 files changed

+51
-6
lines changed

4 files changed

+51
-6
lines changed

Sprint-3/1-implement-and-rewrite-tests/implement/1-get-angle-type.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,18 @@
1515
// execute the code to ensure all tests pass.
1616

1717
function getAngleType(angle) {
18-
// TODO: Implement this function
18+
if (angle > 0 && angle < 90) {
19+
return "Acute angle";
20+
} else if (angle === 90) {
21+
return "Right angle";
22+
} else if (angle > 90 && angle < 180) {
23+
return "Obtuse angle";
24+
} else if (angle === 180) {
25+
return "Straight angle";
26+
} else if (angle > 180 && angle < 360) {
27+
return "Reflex angle";
28+
}
29+
return "Invalid angle";
1930
}
2031

2132
// The line below allows us to load the getAngleType function into tests in other files.

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,15 @@
1111
// execute the code to ensure all tests pass.
1212

1313
function isProperFraction(numerator, denominator) {
14-
// TODO: Implement this function
14+
if (denominator === 0) {
15+
return false;
16+
}
17+
return Math.abs(numerator) < Math.abs(denominator);
1518
}
1619

20+
21+
22+
1723
// The line below allows us to load the isProperFraction function into tests in other files.
1824
// This will be useful in the "rewrite tests with jest" step.
1925
module.exports = isProperFraction;

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

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,35 @@
2222
// execute the code to ensure all tests pass.
2323

2424
function getCardValue(card) {
25-
// TODO: Implement this function
25+
const rank = card.slice(0, -1);
26+
const suit = card.slice(-1);
27+
const validSuits = ["♠", "♥", "♦", "♣"];
28+
const validRanks = [
29+
"A",
30+
"2",
31+
"3",
32+
"4",
33+
"5",
34+
"6",
35+
"7",
36+
"8",
37+
"9",
38+
"10",
39+
"J",
40+
"Q",
41+
"K",
42+
];
43+
44+
if (!validSuits.includes(suit) || !validRanks.includes(rank)) {
45+
throw new Error("Invalid card");
46+
}
47+
if (rank === "A") {
48+
return 11;
49+
}
50+
if (rank === "J" || rank === "Q" || rank === "K") {
51+
return 10;
52+
}
53+
return parseInt(rank);
2654
}
2755

2856
// The line below allows us to load the getCardValue function into tests in other files.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"keywords": [],
1010
"author": "Code Your Future",
1111
"license": "ISC",
12-
"dependencies": {
13-
"jest": "^29.7.0"
12+
"devDependencies": {
13+
"jest": "^30.2.0"
1414
}
15-
}
15+
}

0 commit comments

Comments
 (0)