1111// execute the code to ensure all tests pass.
1212
1313function isProperFraction ( numerator , denominator ) {
14- return numerator >= 0 && denominator > 0 && numerator < denominator ;
14+ if ( denominator === 0 ) {
15+ return false ;
16+ }
17+ return Math . abs ( numerator ) < Math . abs ( denominator ) ;
1518}
1619
1720// The line below allows us to load the isProperFraction function into tests in other files.
@@ -35,5 +38,9 @@ assertEquals(isProperFraction(3, 5), true);
3538assertEquals ( isProperFraction ( 0 , 5 ) , true ) ;
3639assertEquals ( isProperFraction ( 4 , 4 ) , false ) ;
3740assertEquals ( isProperFraction ( 7 , 3 ) , false ) ;
38- assertEquals ( isProperFraction ( - 1 , 2 ) , false ) ;
39- assertEquals ( isProperFraction ( 4 , 0 ) , false ) ;
41+ assertEquals ( isProperFraction ( - 1 , 2 ) , true ) ;
42+ assertEquals ( isProperFraction ( 4 , 0 ) , false ) ;
43+ assertEquals ( isProperFraction ( - 4 , 5 ) , true ) ;
44+ assertEquals ( isProperFraction ( 4 , - 5 ) , true ) ;
45+ assertEquals ( isProperFraction ( - 4 , - 5 ) , true ) ;
46+ assertEquals ( isProperFraction ( - 9 , 5 ) , false ) ;
0 commit comments