Skip to content

Commit f0ca3d7

Browse files
committed
Implemented the function and tested
1 parent b31a586 commit f0ca3d7

1 file changed

Lines changed: 39 additions & 1 deletion

File tree

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

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,19 @@
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+
} else {
29+
return "Invalid angle";
30+
}
1931
}
2032

2133
// The line below allows us to load the getAngleType function into tests in other files.
@@ -34,4 +46,30 @@ function assertEquals(actualOutput, targetOutput) {
3446
// TODO: Write tests to cover all cases, including boundary and invalid cases.
3547
// Example: Identify Right Angles
3648
const right = getAngleType(90);
49+
const acute = getAngleType(66);
50+
const obtuse = getAngleType(109);
51+
const straight = getAngleType(180);
52+
const reflex = getAngleType(222);
53+
const invalid = getAngleType(366);
54+
const boundary = getAngleType(0);
55+
const invalidBoundary = getAngleType(360)
56+
const acuteBoundary = getAngleType(1)
57+
const acuteSecondBoundary = getAngleType(89)
58+
const obtuseBoundary = getAngleType(91)
59+
const reflexBoundary = getAngleType(181)
60+
61+
62+
3763
assertEquals(right, "Right angle");
64+
assertEquals(acute, "Acute angle");
65+
assertEquals(obtuse, "Obtuse angle");
66+
assertEquals(straight, "Straight angle");
67+
assertEquals(reflex, "Reflex angle")
68+
assertEquals(invalid, "Invalid angle")
69+
assertEquals(invalidBoundary, "Invalid angle")
70+
assertEquals(acuteBoundary, "Acute angle")
71+
assertEquals(acuteSecondBoundary, "Acute angle")
72+
assertEquals(obtuseBoundary, "Obtuse angle")
73+
assertEquals(reflexBoundary, "Reflex angle")
74+
75+

0 commit comments

Comments
 (0)