Skip to content

Commit 6e25287

Browse files
Implement getAngleType function to classify angles and test the cases
1 parent 793cbac commit 6e25287

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,22 @@
1616

1717
function getAngleType(angle) {
1818
// TODO: Implement this function
19+
if ( angle <=0 || angle >= 360 ) {
20+
return "Invalid angle";
21+
}
22+
if ( 0 < angle && angle < 90 ){
23+
return "Acute angle";
24+
}
25+
if (angle === 90){
26+
return "Right angle";
27+
}
28+
if ( 90 < angle && angle < 180){
29+
return "Obtuse angle";
30+
}
31+
if (angle === 180){
32+
return "Straight angle";
33+
}
34+
return "Reflex angle";
1935
}
2036

2137
// The line below allows us to load the getAngleType function into tests in other files.
@@ -35,3 +51,13 @@ function assertEquals(actualOutput, targetOutput) {
3551
// Example: Identify Right Angles
3652
const right = getAngleType(90);
3753
assertEquals(right, "Right angle");
54+
const acute = getAngleType(45);
55+
assertEquals(acute, "Acute angle");
56+
const obtuse = getAngleType(120);
57+
assertEquals(obtuse, "Obtuse angle");
58+
const straight = getAngleType(180);
59+
assertEquals(straight, "Straight angle");
60+
const reflex = getAngleType(270);
61+
assertEquals(reflex, "Reflex angle");
62+
const zero = getAngleType(0);
63+
assertEquals(zero, "Invalid angle");

0 commit comments

Comments
 (0)