1515// execute the code to ensure all tests pass.
1616
1717function getAngleType ( angle ) {
18- if ( angle < 90 ) {
18+ if ( angle > 0 && angle < 90 ) {
1919 return "Acute angle" ;
2020 } else if ( angle === 90 ) {
2121 return "Right angle" ;
@@ -26,7 +26,7 @@ function getAngleType(angle) {
2626 } else if ( angle > 180 && angle < 360 ) {
2727 return "Reflex angle" ;
2828 }
29- return "invalid angle" ;
29+ return "Invalid angle" ;
3030
3131}
3232
@@ -37,14 +37,31 @@ module.exports = getAngleType;
3737// This helper function is written to make our assertions easier to read.
3838// If the actual output matches the target output, the test will pass
3939function assertEquals ( actualOutput , targetOutput ) {
40+
4041 console . assert (
4142 actualOutput === targetOutput ,
42- `Expected ${ actualOutput } to equal ${ targetOutput } `
43+ `❌ Error: expected ${ actualOutput } to equal ${ targetOutput } `
4344 ) ;
45+
46+ if ( actualOutput === targetOutput ) {
47+ console . log ( `✅ Test passed: ${ actualOutput } equals ${ targetOutput } ` ) ;
48+ }
49+
4450}
4551
4652// TODO: Write tests to cover all cases, including boundary and invalid cases.
4753// Example: Identify Right Angles
48- const right = getAngleType ( 90 ) ;
54+ const right = getAngleType ( 45 ) ;
4955assertEquals ( right , "Right angle" ) ;
56+ const acute = getAngleType ( 45 ) ;
57+ assertEquals ( acute , "Acute angle" ) ;
58+ const obtuse = getAngleType ( 180 ) ;
59+ assertEquals ( obtuse , "Obtuse angle" ) ;
60+ const straight = getAngleType ( 180 ) ;
61+ assertEquals ( straight , "Straight angle" ) ;
62+ const reflex = getAngleType ( 240 ) ;
63+ assertEquals ( reflex , "Reflex angle" ) ;
64+ const invalid = getAngleType ( - 10 ) ;
65+ assertEquals ( invalid , "Invalid angle" ) ;
66+ console . log ( "✓ All test executed!" ) ;
5067
0 commit comments