Skip to content

Commit f17635b

Browse files
committed
Implement getAngleType function and add assertion tests
1 parent 8f3d6cf commit f17635b

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

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

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

1010
function getAngleType(angle) {
11+
angleType = "";
1112
if (angle === 90) {
12-
return "Right angle";
13+
angleType = "Right angle";
14+
} else if (angle < 90) {
15+
angleType = "Acute angle";
16+
} else if (angle > 90 && angle < 180) {
17+
angleType = "Obtuse angle";
18+
} else if (angle === 180) {
19+
angleType = "Straight angle";
20+
} else if (angle > 180 && angle < 360) {
21+
angleType = "Reflex angle";
1322
}
23+
return angleType;
1424
// Run the tests, work out what Case 2 is testing, and implement the required code here.
1525
// Then keep going for the other cases, one at a time.
1626
}
@@ -37,6 +47,7 @@ function assertEquals(actualOutput, targetOutput) {
3747
// Case 1: Identify Right Angles:
3848
// When the angle is exactly 90 degrees,
3949
// Then the function should return "Right angle"
50+
4051
const right = getAngleType(90);
4152
assertEquals(right, "Right angle");
4253

@@ -51,13 +62,18 @@ assertEquals(acute, "Acute angle");
5162
// Then the function should return "Obtuse angle"
5263
const obtuse = getAngleType(120);
5364
// ====> write your test here, and then add a line to pass the test in the function above
65+
assertEquals(obtuse, "Obtuse angle");
5466

5567
// Case 4: Identify Straight Angles:
5668
// When the angle is exactly 180 degrees,
5769
// Then the function should return "Straight angle"
5870
// ====> write your test here, and then add a line to pass the test in the function above
71+
const straight = getAngleType(180);
72+
assertEquals(straight, "Straight angle");
5973

6074
// Case 5: Identify Reflex Angles:
6175
// When the angle is greater than 180 degrees and less than 360 degrees,
6276
// 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
77+
// ====> write your test here, and then add a line to pass the test in the function above
78+
const reflex = getAngleType(270);
79+
assertEquals(reflex, "Reflex angle");

0 commit comments

Comments
 (0)