1111// execute the code to ensure all tests pass.
1212
1313function isProperFraction ( numerator , denominator ) {
14- // TODO: Implement this function
14+ if ( denominator === 0 ) {
15+ return false ;
16+ }
17+
18+ return Math . abs ( numerator ) < Math . abs ( denominator ) ;
1519}
1620
21+
1722// The line below allows us to load the isProperFraction function into tests in other files.
1823// This will be useful in the "rewrite tests with jest" step.
1924module . exports = isProperFraction ;
@@ -31,3 +36,23 @@ function assertEquals(actualOutput, targetOutput) {
3136
3237// Example: 1/2 is a proper fraction
3338assertEquals ( isProperFraction ( 1 , 2 ) , true ) ;
39+
40+ // Equal numbers → will not be proper
41+ assertEquals ( isProperFraction ( 2 , 2 ) , false ) ;
42+
43+ // Improper fractions
44+ assertEquals ( isProperFraction ( 5 , 4 ) , false ) ;
45+ assertEquals ( isProperFraction ( 10 , 3 ) , false ) ;
46+
47+ // Zero numerator → will be proper
48+ assertEquals ( isProperFraction ( 0 , 5 ) , true ) ;
49+
50+ // Negative numbers
51+ assertEquals ( isProperFraction ( - 1 , 2 ) , true ) ;
52+ assertEquals ( isProperFraction ( 1 , - 2 ) , true ) ;
53+ assertEquals ( isProperFraction ( - 3 , - 2 ) , false ) ;
54+
55+ // Denominator zero
56+ assertEquals ( isProperFraction ( 1 , 0 ) , false ) ;
57+ assertEquals ( isProperFraction ( 0 , 0 ) , false ) ;
58+
0 commit comments