1212
1313function isProperFraction ( numerator , denominator ) {
1414 // TODO: Implement this function
15+ if ( denominator === 0 ) {
16+ return false ;
17+ }
18+
19+ return Math . abs ( numerator ) < Math . abs ( denominator ) ;
1520}
1621
1722// The line below allows us to load the isProperFraction function into tests in other files.
@@ -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