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+ } else if ( angle === 90 ) {
21+ return "Right angle" ;
22+ } else if ( angle > 90 && angle < 180 ) {
23+ return "Obtuse angle" ;
24+ } else if ( angle === 180 ) {
25+ return "Straight angle" ;
26+ } else if ( angle > 180 && angle < 360 ) {
27+ return "Reflex angle" ;
28+ } else {
29+ return "Invalid angle" ;
30+ }
1931}
2032
33+ console . assert ( getAngleType ( 45 ) === "Acute angle" ) ;
34+ console . assert ( getAngleType ( 90 ) === "Right angle" ) ;
35+ console . assert ( getAngleType ( 120 ) === "Obtuse angle" ) ;
36+ console . assert ( getAngleType ( 180 ) === "Straight angle" ) ;
37+ console . assert ( getAngleType ( 270 ) === "Reflex angle" ) ;
38+ console . assert ( getAngleType ( 0 ) === "Invalid angle" ) ;
39+ console . assert ( getAngleType ( 360 ) === "Invalid angle" ) ;
40+
2141// The line below allows us to load the getAngleType function into tests in other files.
2242// This will be useful in the "rewrite tests with jest" step.
2343module . exports = getAngleType ;
@@ -35,3 +55,27 @@ function assertEquals(actualOutput, targetOutput) {
3555// Example: Identify Right Angles
3656const right = getAngleType ( 90 ) ;
3757assertEquals ( right , "Right angle" ) ;
58+
59+ // Example: Identify Acute Angles
60+ const acute = getAngleType ( 45 ) ;
61+ assertEquals ( acute , "Acute angle" ) ;
62+
63+ // Example: Identify Obtuse Angles
64+ const obtuse = getAngleType ( 120 ) ;
65+ assertEquals ( obtuse , "Obtuse angle" ) ;
66+
67+ // Example: Identify Straight Angles
68+ const straight = getAngleType ( 180 ) ;
69+ assertEquals ( straight , "Straight angle" ) ;
70+
71+ // Example: Identify Reflex Angles
72+ const reflex = getAngleType ( 270 ) ;
73+ assertEquals ( reflex , "Reflex angle" ) ;
74+
75+ // Example: Identify Invalid Angles
76+ const invalid1 = getAngleType ( 0 ) ;
77+ assertEquals ( invalid1 , "Invalid angle" ) ;
78+
79+ // Example: Identify Invalid Angles
80+ const invalid2 = getAngleType ( 360 ) ;
81+ assertEquals ( invalid2 , "Invalid angle" ) ;
0 commit comments