@@ -11,8 +11,21 @@ function getAngleType(angle) {
1111 if ( angle === 90 ) {
1212 return "Right angle" ;
1313 }
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.
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.
16+ if ( angle < 90 && angle > 0 ) {
17+ return "Acute angle" ;
18+ }
19+ if ( angle > 90 && angle < 180 ) {
20+ return "Obtuse angle" ;
21+ }
22+ if ( angle === 180 ) {
23+ return "Straight angle" ;
24+ }
25+ if ( angle > 180 && angle < 360 ) {
26+ return "Reflex angle" ;
27+ }
28+ return "Invalid angle" ;
1629}
1730
1831// The line below allows us to load the getAngleType function into tests in other files.
@@ -50,14 +63,36 @@ assertEquals(acute, "Acute angle");
5063// When the angle is greater than 90 degrees and less than 180 degrees,
5164// Then the function should return "Obtuse angle"
5265const obtuse = getAngleType ( 120 ) ;
66+ assertEquals ( obtuse , "Obtuse angle" ) ;
5367// ====> write your test here, and then add a line to pass the test in the function above
5468
5569// Case 4: Identify Straight Angles:
5670// When the angle is exactly 180 degrees,
5771// Then the function should return "Straight angle"
72+ const straight = getAngleType ( 180 ) ;
73+ assertEquals ( straight , "Straight angle" ) ;
5874// ====> write your test here, and then add a line to pass the test in the function above
5975
6076// Case 5: Identify Reflex Angles:
6177// When the angle is greater than 180 degrees and less than 360 degrees,
6278// 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
79+ const reflex = getAngleType ( 250 ) ;
80+ assertEquals ( reflex , "Reflex angle" ) ;
81+ // ====> write your test here, and then add a line to pass the test in the function above
82+
83+ let angle = 90 ;
84+ console . log ( angle + " degrees is a " + getAngleType ( angle ) ) ;
85+ angle = 45 ;
86+ console . log ( angle + " degrees is a " + getAngleType ( angle ) ) ;
87+ angle = 120 ;
88+ console . log ( angle + " degrees is a " + getAngleType ( angle ) ) ;
89+ angle = 250 ;
90+ console . log ( angle + " degrees is a " + getAngleType ( angle ) ) ;
91+ angle = 180 ;
92+ console . log ( angle + " degrees is a " + getAngleType ( angle ) ) ;
93+ angle = 360 ;
94+ console . log ( angle + " degrees is a " + getAngleType ( angle ) ) ;
95+ angle = - 10 ;
96+ console . log ( angle + " degrees is a " + getAngleType ( angle ) ) ;
97+ angle = 0 ;
98+ console . log ( angle + " degrees is a " + getAngleType ( angle ) ) ;
0 commit comments