File tree Expand file tree Collapse file tree 2 files changed +33
-4
lines changed
Sprint-3/1-implement-and-rewrite-tests/implement Expand file tree Collapse file tree 2 files changed +33
-4
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 <= 0 || angle >= 360 ) return "invalid angle" ;
1919}
2020
21+ if ( angle < 90 ) {
22+ return "acute angle" ;
23+ }
24+
25+ if ( angle === 90 ) {
26+ return "right angle" ;
27+ }
28+
29+ if ( angle < 180 ) {
30+ return "obtuse angle" ;
31+ }
32+
33+ if ( angle === 180 ) {
34+ return " straight angle" ;
35+ }
36+
37+ if ( angle < 360 ) {
38+ return "reflext angle" ;
39+ }
40+
41+ // TODO: Implement this function
42+
2143// The line below allows us to load the getAngleType function into tests in other files.
2244// This will be useful in the "rewrite tests with jest" step.
2345module . exports = getAngleType ;
@@ -30,6 +52,13 @@ function assertEquals(actualOutput, targetOutput) {
3052 `Expected ${ actualOutput } to equal ${ targetOutput } `
3153 ) ;
3254}
55+ // Test
56+ assertEquals ( getAngleType ( 45 ) , "Acute angle" ) ;
57+ assertEquals ( getAngleType ( 90 ) , "Right angle" ) ;
58+ assertEquals ( getAngleType ( 120 ) , "Obtuse angle" ) ;
59+ assertEquals ( getAngleType ( 180 ) , "Straight angle" ) ;
60+ assertEquals ( getAngleType ( 270 ) , "Reflex angle" ) ;
61+ assertEquals ( getAngleType ( 390 ) , "invalid angle" ) ;
3362
3463// TODO: Write tests to cover all cases, including boundary and invalid cases.
3564// Example: Identify Right Angles
Original file line number Diff line number Diff line change 99 "keywords" : [],
1010 "author" : " Code Your Future" ,
1111 "license" : " ISC" ,
12- "dependencies " : {
13- "jest" : " ^29.7 .0"
12+ "devDependencies " : {
13+ "jest" : " ^30.3 .0"
1414 }
15- }
15+ }
You can’t perform that action at this time.
0 commit comments