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+ return "Acute angle" ;
20+ }
21+ if ( angle === 90 ) {
22+ return "Right angle" ;
23+ }
24+ if ( angle > 90 && angle < 180 ) {
25+ return "Obtuse angle" ;
26+ }
27+ if ( angle === 180 ) {
28+ return "Straight angle" ;
29+ }
30+ if ( angle > 180 && angle < 360 ) {
31+ return "Reflex angle" ;
32+ }
33+ return "Invalid angle" ;
1934}
2035
2136// The line below allows us to load the getAngleType function into tests in other files.
2237// This will be useful in the "rewrite tests with jest" step.
2338module . exports = getAngleType ;
24-
2539// This helper function is written to make our assertions easier to read.
2640// If the actual output matches the target output, the test will pass
2741function assertEquals ( actualOutput , targetOutput ) {
@@ -33,5 +47,15 @@ function assertEquals(actualOutput, targetOutput) {
3347
3448// TODO: Write tests to cover all cases, including boundary and invalid cases.
3549// Example: Identify Right Angles
50+ const acute = getAngleType ( 45 ) ;
51+ assertEquals ( acute , "Acute angle" ) ;
3652const right = getAngleType ( 90 ) ;
3753assertEquals ( right , "Right angle" ) ;
54+ const obtuse = getAngleType ( 135 ) ;
55+ assertEquals ( obtuse , "Obtuse angle" ) ;
56+ const straight = getAngleType ( 180 ) ;
57+ assertEquals ( straight , "Straight angle" ) ;
58+ const reflex = getAngleType ( 270 ) ;
59+ assertEquals ( reflex , "Reflex angle" ) ;
60+ const invalidAngle = getAngleType ( - 10 ) ;
61+ assertEquals ( invalidAngle , "Invalid angle" ) ;
0 commit comments