Skip to content

Commit bf6c25f

Browse files
committed
feat: implement getAngleType function with tests for all angle cases
1 parent 57000fc commit bf6c25f

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

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

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,28 @@ function getAngleType(angle) {
1111
if (angle === 90) {
1212
return "Right angle";
1313
}
14-
// Run the tests, work out what Case 2 is testing, and implement the required code here.
15-
// Then keep going for the other cases, one at a time.
14+
// Run the tests, work out what Case 2 is testing, and implement the required code here.
15+
// Then keep going for the other cases, one at a time.
16+
17+
// Case 2: Identify Acute Angles
18+
if (angle < 90) {
19+
return "Acute angle";
20+
}
21+
22+
// Case 3: Identify Obtuse Angles
23+
if (angle > 90 && angle < 180) {
24+
return "Obtuse angle";
25+
}
26+
27+
// Case 4: Identify Straight Angles
28+
if (angle === 180) {
29+
return "Straight angle";
30+
}
31+
32+
// Case 5: Identify Reflex Angles
33+
if (angle > 180 && angle < 360) {
34+
return "Reflex angle";
35+
}
1636
}
1737

1838
// The line below allows us to load the getAngleType function into tests in other files.
@@ -51,13 +71,18 @@ assertEquals(acute, "Acute angle");
5171
// Then the function should return "Obtuse angle"
5272
const obtuse = getAngleType(120);
5373
// ====> write your test here, and then add a line to pass the test in the function above
74+
assertEquals(obtuse, "Obtuse angle");
5475

5576
// Case 4: Identify Straight Angles:
5677
// When the angle is exactly 180 degrees,
5778
// Then the function should return "Straight angle"
5879
// ====> write your test here, and then add a line to pass the test in the function above
80+
const straight = getAngleType(180);
81+
assertEquals(straight, "Straight angle");
5982

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

0 commit comments

Comments
 (0)