1515// execute the code to ensure all tests pass.
1616
1717function getAngleType ( angle ) {
18- // TODO: Implement this function
18+ if ( angle < 0 || angle >= 360 ) return "Invalid angle" ;
19+ if ( angle < 90 ) return "Acute angle" ;
20+ if ( angle === 90 ) return "Right angle" ;
21+ if ( angle > 90 && angle < 180 ) return "Obtuse angle" ;
22+ if ( angle === 180 ) return "Straight angle" ;
23+ return "Reflex angle" ;
1924}
2025
2126// The line below allows us to load the getAngleType function into tests in other files.
@@ -31,7 +36,31 @@ function assertEquals(actualOutput, targetOutput) {
3136 ) ;
3237}
3338
34- // TODO: Write tests to cover all cases, including boundary and invalid cases.
35- // Example: Identify Right Angles
3639const right = getAngleType ( 90 ) ;
3740assertEquals ( right , "Right angle" ) ;
41+
42+ const acute = getAngleType ( 45 ) ;
43+ assertEquals ( acute , "Acute angle" ) ;
44+
45+ const obtuse = getAngleType ( 120 ) ;
46+ assertEquals ( obtuse , "Obtuse angle" ) ;
47+
48+ const straight = getAngleType ( 180 ) ;
49+ assertEquals ( straight , "Straight angle" ) ;
50+
51+ const reflex = getAngleType ( 270 ) ;
52+ assertEquals ( reflex , "Reflex angle" ) ;
53+
54+ const invalid = getAngleType ( - 10 ) ;
55+ assertEquals ( invalid , "Invalid angle" ) ;
56+
57+ const invalid2 = getAngleType ( 360 ) ;
58+ assertEquals ( invalid2 , "Invalid angle" ) ;
59+
60+ console . log ( getAngleType ( 20 ) ) ;
61+ console . log ( getAngleType ( 90 ) ) ;
62+ console . log ( getAngleType ( 120 ) ) ;
63+ console . log ( getAngleType ( 180 ) ) ;
64+ console . log ( getAngleType ( 270 ) ) ;
65+ console . log ( getAngleType ( - 10 ) ) ;
66+ console . log ( getAngleType ( 360 ) ) ;
0 commit comments