1515// execute the code to ensure all tests pass.
1616
1717function getAngleType ( angle ) {
18- // TODO: Implement this function
18+ if ( angle > 0 && angle < 90 )
19+ {
20+ return 'Acute angle' ;
21+ }
22+ else if ( angle === 90 ) {
23+ return 'Right angle'
24+ }
25+ else if ( angle > 90 && angle < 180 )
26+ {
27+ return "Obtuse angle"
28+ }
29+ else if ( angle === 180 )
30+ {
31+ return "Straight angle" ;
32+ }
33+ else if ( angle > 180 && angle < 360 )
34+ {
35+ return "Reflex angle" ;
36+ }
37+ else
38+
39+ {
40+ return "Invalid angle"
41+ }
1942}
2043
2144// The line below allows us to load the getAngleType function into tests in other files.
2245// This will be useful in the "rewrite tests with jest" step.
23- module . exports = getAngleType ;
46+ // module.exports = getAngleType;
2447
2548// This helper function is written to make our assertions easier to read.
2649// If the actual output matches the target output, the test will pass
@@ -33,5 +56,24 @@ function assertEquals(actualOutput, targetOutput) {
3356
3457// TODO: Write tests to cover all cases, including boundary and invalid cases.
3558// Example: Identify Right Angles
36- const right = getAngleType ( 90 ) ;
59+ let invalid = getAngleType ( 0 ) ;
60+ assertEquals ( invalid , "Invalid angle" ) ;
61+ let acute = getAngleType ( 1 ) ;
62+ assertEquals ( acute , "Acute angle" ) ;
63+ acute = getAngleType ( 89 ) ;
64+ assertEquals ( acute , "Acute angle" ) ;
65+ let right = getAngleType ( 90 ) ;
3766assertEquals ( right , "Right angle" ) ;
67+ let obtuse = getAngleType ( 91 ) ;
68+ assertEquals ( obtuse , "Obtuse angle" ) ;
69+ obtuse = getAngleType ( 179 ) ;
70+ assertEquals ( obtuse , "Obtuse angle" ) ;
71+ const straight = getAngleType ( 180 ) ;
72+ assertEquals ( straight , "Straight angle" ) ;
73+ let reflex = getAngleType ( 181 ) ;
74+ assertEquals ( reflex , "Reflex angle" ) ;
75+ reflex = getAngleType ( 359 ) ;
76+ assertEquals ( reflex , "Reflex angle" ) ;
77+ invalid = getAngleType ( 400 ) ;
78+ assertEquals ( invalid , "Invalid angle" ) ;
79+
0 commit comments