Skip to content

Commit 54d60ac

Browse files
committed
wrote the code and jest tests for it
1 parent dd8467a commit 54d60ac

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

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

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,22 @@
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+
}
21+
if (angle === 90) {
22+
return "Right angle";
23+
}
24+
if (angle > 90 && angle < 180) {
25+
return "Obtuse angle";
26+
}
27+
if (angle === 180) {
28+
return "Straight angle";
29+
}
30+
if (angle > 180 && angle < 360) {
31+
return "Reflex angle";
32+
}
33+
return "Invalid angle";
1934
}
2035

2136
// The line below allows us to load the getAngleType function into tests in other files.
@@ -35,3 +50,21 @@ function assertEquals(actualOutput, targetOutput) {
3550
// Example: Identify Right Angles
3651
const right = getAngleType(90);
3752
assertEquals(right, "Right angle");
53+
54+
const acute = getAngleType(45);
55+
assertEquals(acute, "Acute angle");
56+
57+
const obtuse = getAngleType(135);
58+
assertEquals(obtuse, "Obtuse angle");
59+
60+
const straight = getAngleType(180);
61+
assertEquals(straight, "Straight angle");
62+
63+
const reflex = getAngleType(270);
64+
assertEquals(reflex, "Reflex angle");
65+
66+
const invalid = getAngleType(-45);
67+
assertEquals(invalid, "Invalid angle");
68+
69+
const invalid2 = getAngleType(361);
70+
assertEquals(invalid2, "Invalid angle");

0 commit comments

Comments
 (0)