88// Then, write the next test! :) Go through this process until all the cases are implemented
99
1010function getAngleType ( angle ) {
11+ // Case 1: Identify Right Angles
1112 if ( angle === 90 ) {
1213 return "Right angle" ;
1314 }
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.
15+
16+ // Case 2: Identify Acute Angles
17+ if ( angle < 90 ) {
18+ return "Acute angle" ;
19+ }
20+
21+ // Case 3: Identify Obtuse Angles
22+ if ( angle > 90 && angle < 180 ) {
23+ return "Obtuse angle" ;
24+ }
25+
26+ // Case 4: Identify Straight Angles
27+ if ( angle === 180 ) {
28+ return "Straight angle" ;
29+ }
30+
31+ // Case 5: Identify Reflex Angles
32+ if ( angle > 180 && angle < 360 ) {
33+ return "Reflex angle" ;
34+ }
35+
36+ // Optional: handle invalid angles
37+ return "Invalid angle" ;
1638}
1739
1840// The line below allows us to load the getAngleType function into tests in other files.
@@ -50,14 +72,18 @@ assertEquals(acute, "Acute angle");
5072// When the angle is greater than 90 degrees and less than 180 degrees,
5173// Then the function should return "Obtuse angle"
5274const obtuse = getAngleType ( 120 ) ;
53- // ====> write your test here, and then add a line to pass the test in the function above
75+ assertEquals ( obtuse , "Obtuse angle" ) ;
5476
5577// Case 4: Identify Straight Angles:
5678// When the angle is exactly 180 degrees,
5779// Then the function should return "Straight angle"
58- // ====> 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+ const reflex = getAngleType ( 270 ) ;
87+ assertEquals ( reflex , "Reflex angle" ) ;
88+
89+ console . log ( "All tests ran! If no errors, all passed." ) ;
0 commit comments