File tree Expand file tree Collapse file tree 1 file changed +31
-1
lines changed
Sprint-3/1-implement-and-rewrite-tests/implement Expand file tree Collapse file tree 1 file changed +31
-1
lines changed Original file line number Diff line number Diff line change 1515// execute the code to ensure all tests pass.
1616
1717function getAngleType ( angle ) {
18- // TODO: Implement this function
18+ if ( angle < 90 ) {
19+ return "Acute angle" ;
20+ }
21+ if ( angle === 90 ) {
22+ return "Right angle" ;
23+ }
24+ if ( angle < 180 ) {
25+ return "Obtuse angle" ;
26+ }
27+ if ( angle === 180 ) {
28+ return "Straight angle" ;
29+ }
30+ if ( 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.
@@ -33,5 +48,20 @@ function assertEquals(actualOutput, targetOutput) {
3348
3449// TODO: Write tests to cover all cases, including boundary and invalid cases.
3550// Example: Identify Right Angles
51+ const acute = getAngleType ( 70 ) ;
52+ assertEquals ( acute , "Acute angle" ) ;
53+
3654const right = getAngleType ( 90 ) ;
3755assertEquals ( right , "Right angle" ) ;
56+
57+ const obtuse = getAngleType ( 95 ) ;
58+ assertEquals ( obtuse , "Obtuse angle" ) ;
59+
60+ const straight = getAngleType ( 180 ) ;
61+ assertEquals ( straight , "Straight angle" ) ;
62+
63+ const reflex = getAngleType ( 280 ) ;
64+ assertEquals ( reflex , "Reflex angle" ) ;
65+
66+ const invalid = getAngleType ( 180 ) ;
67+ assertEquals ( invalid , "Invalid angle" ) ;
You can’t perform that action at this time.
0 commit comments