Skip to content

Commit 4723bb9

Browse files
committed
implement getAngleType function with all angle cases and tests
1 parent 2d1e8dd commit 4723bb9

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

Sprint-3/1-key-implement/1-get-angle-type.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@
88
// Then, write the next test! :) Go through this process until all the cases are implemented
99

1010
function getAngleType(angle) {
11-
if (angle === 90) return "Right angle";
12-
// read to the end, complete line 36, then pass your test here
11+
if (angle === 90) return "Right angle";
12+
if (angle < 90) return "Acute angle";
13+
if (angle > 90 && angle < 180) return "Obtuse angle";
14+
if (angle === 180) return "Straight angle";
15+
if (angle > 180 && angle < 360) return "Reflex angle";
1316
}
1417

1518
// we're going to use this helper function to make our assertions easier to read
@@ -39,18 +42,23 @@ assertEquals(right, "Right angle");
3942
const acute = getAngleType(45);
4043
assertEquals(acute, "Acute angle");
4144

45+
4246
// Case 3: Identify Obtuse Angles:
4347
// When the angle is greater than 90 degrees and less than 180 degrees,
4448
// Then the function should return "Obtuse angle"
4549
const obtuse = getAngleType(120);
46-
// ====> write your test here, and then add a line to pass the test in the function above
50+
assertEquals(obtuse, "Obtuse angle");
51+
4752

4853
// Case 4: Identify Straight Angles:
4954
// When the angle is exactly 180 degrees,
5055
// Then the function should return "Straight angle"
51-
// ====> write your test here, and then add a line to pass the test in the function above
56+
const straight = getAngleType(180);
57+
assertEquals(straight, "Straight angle");
58+
5259

5360
// Case 5: Identify Reflex Angles:
5461
// When the angle is greater than 180 degrees and less than 360 degrees,
5562
// Then the function should return "Reflex angle"
56-
// ====> write your test here, and then add a line to pass the test in the function above
63+
const reflex = getAngleType(270);
64+
assertEquals(reflex, "Reflex angle");

0 commit comments

Comments
 (0)