1515// execute the code to ensure all tests pass.
1616
1717function getAngleType ( angle ) {
18+ // Returns the type of angle based on the number of degrees given.
1819 // TODO: Implement this function
20+ if ( angle > 0 && angle < 90 ) {
21+ return "Acute angle" ;
22+ } else if ( angle === 90 ) {
23+ return "Right angle" ;
24+ } else if ( angle > 90 && angle < 180 ) {
25+ return "Obtuse angle" ;
26+ } else if ( angle === 180 ) {
27+ return "Straight angle" ;
28+ } else if ( angle > 180 && angle < 360 ) {
29+ return "Reflex angle" ;
30+ } else {
31+ return "Invalid angle" ;
32+ }
1933}
2034
2135// The line below allows us to load the getAngleType function into tests in other files.
@@ -35,3 +49,37 @@ function assertEquals(actualOutput, targetOutput) {
3549// Example: Identify Right Angles
3650const right = getAngleType ( 90 ) ;
3751assertEquals ( right , "Right angle" ) ;
52+
53+ // Case 2: Identify Acute Angles
54+ // When the angle is between 0 and 90 degrees,
55+ // then should return "Acute angle"
56+ const acute = getAngleType ( 45 ) ;
57+ assertEquals ( acute , "Acute angle" ) ;
58+
59+ // Case 3: Identify Obtuse Angles
60+ // When the angle is between 90 and 180 degrees,
61+ // then should return "Obtuse angle"
62+ const obtuse = getAngleType ( 135 ) ;
63+ assertEquals ( obtuse , "Obtuse angle" ) ;
64+
65+ // Case 4: Identify Straight Angles
66+ // When the angle is exactly 180 degrees,
67+ // then should return "Straight angle"
68+ const straight = getAngleType ( 180 ) ;
69+ assertEquals ( straight , "Straight angle" ) ;
70+
71+ // Case 5: Identify Reflex Angles
72+ // When the angle is between 180 and 360 degrees,
73+ // then should return "Reflex angle"
74+ const reflex = getAngleType ( 270 ) ;
75+ assertEquals ( reflex , "Reflex angle" ) ;
76+
77+ // Case 6: Identify Invalid Angles
78+ // When the angle is negative or 360+
79+ // then should return "Invalid angle"
80+
81+ const invalid1 = getAngleType ( - 30 ) ;
82+ assertEquals ( invalid1 , "Invalid angle" ) ;
83+
84+ const invalid2 = getAngleType ( 400 ) ;
85+ assertEquals ( invalid2 , "Invalid angle" ) ;
0 commit comments