Skip to content

Commit e5625a3

Browse files
committed
implement angle assetrtions
1 parent 3372770 commit e5625a3

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

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

Lines changed: 31 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 < 90) {
19+
return "Acute angle";
20+
}
21+
if (angle === 90) {
22+
return "Right angle";
23+
}
24+
if (angle < 180) {
25+
return "Obtuse angle";
26+
}
27+
if (angle === 180) {
28+
return "Straight angle";
29+
}
30+
if (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.
@@ -33,5 +48,20 @@ function assertEquals(actualOutput, targetOutput) {
3348

3449
// TODO: Write tests to cover all cases, including boundary and invalid cases.
3550
// Example: Identify Right Angles
51+
const acute = getAngleType(70);
52+
assertEquals(acute, "Acute angle");
53+
3654
const right = getAngleType(90);
3755
assertEquals(right, "Right angle");
56+
57+
const obtuse = getAngleType(95);
58+
assertEquals(obtuse, "Obtuse angle");
59+
60+
const straight = getAngleType(180);
61+
assertEquals(straight, "Straight angle");
62+
63+
const reflex = getAngleType(280);
64+
assertEquals(reflex, "Reflex angle");
65+
66+
const invalid = getAngleType(180);
67+
assertEquals(invalid, "Invalid angle");

0 commit comments

Comments
 (0)