88// Then, write the next test! :) Go through this process until all the cases are implemented
99
1010function getAngleType ( angle ) {
11+ if ( angle === undefined || isNaN ( angle ) ) {
12+ return "Invalid angle: Please provide a valid number" ;
13+ }
14+
15+ if ( angle < 0 || angle > 360 ) {
16+ return "Invalid angle: Angle must be between 0 and 360 degrees" ;
17+ }
18+
19+ if ( angle === 360 || angle === 0 ) return "Full rotation" ;
20+
1121 if ( angle === 90 ) return "Right angle" ;
1222 if ( angle < 90 ) return "Acute angle" ;
1323 if ( angle > 90 && angle < 180 ) return "Obtuse angle" ;
1424 if ( angle === 180 ) return "Straight angle" ;
1525 if ( angle > 180 && angle < 360 ) return "Reflex angle" ;
16- // read to the end, complete line 36, then pass your test here
1726}
1827
1928// we're going to use this helper function to make our assertions easier to read
@@ -60,4 +69,26 @@ assertEquals(straight, "Straight angle");
6069// Then the function should return "Reflex angle"
6170// ====> write your test here, and then add a line to pass the test in the function above
6271const reflex = getAngleType ( 270 ) ;
63- assertEquals ( reflex , "Reflex angle" ) ;
72+ assertEquals ( reflex , "Reflex angle" ) ;
73+
74+ // Case 6: Identify Full Rotation:
75+ // When the angle is exactly 360 degrees or 0 degrees,
76+ // Then the function should return "Full rotation"
77+ const fullRotation = getAngleType ( 360 ) ;
78+ assertEquals ( fullRotation , "Full rotation" ) ;
79+ const zeroAngle = getAngleType ( 0 ) ;
80+ assertEquals ( zeroAngle , "Full rotation" ) ;
81+
82+ // Case 7: Handle missing input:
83+ // When no angle is provided,
84+ // Then the function should return an error message
85+ const noAngle = getAngleType ( ) ;
86+ assertEquals ( noAngle , "Invalid angle: Please provide a valid number" ) ;
87+
88+ // Case 8: Handle invalid angle values:
89+ // When an angle outside the valid range (0-360 degrees) is provided,
90+ // Then the function should return an error message
91+ const tooBig = getAngleType ( 361 ) ;
92+ assertEquals ( tooBig , "Invalid angle: Angle must be between 0 and 360 degrees" ) ;
93+ const negative = getAngleType ( - 10 ) ;
94+ assertEquals ( negative , "Invalid angle: Angle must be between 0 and 360 degrees" ) ;
0 commit comments