1111// execute the code to ensure all tests pass.
1212
1313function isProperFraction ( numerator , denominator ) {
14- // TODO: Implement this function
14+ if ( denominator === 0 ) return false ; // A fraction with a zero denominator is not valid
15+ if ( Math . abs ( numerator ) >= Math . abs ( denominator ) ) return false ; // Not a proper fraction
16+ return true ; // Is a proper fraction
1517}
1618
1719// The line below allows us to load the isProperFraction function into tests in other files.
@@ -31,3 +33,15 @@ function assertEquals(actualOutput, targetOutput) {
3133
3234// Example: 1/2 is a proper fraction
3335assertEquals ( isProperFraction ( 1 , 2 ) , true ) ;
36+ assertEquals ( isProperFraction ( 2 , 2 ) , false ) ;
37+ assertEquals ( isProperFraction ( 2 , 1 ) , false ) ;
38+ assertEquals ( isProperFraction ( 0 , 2 ) , true ) ;
39+ assertEquals ( isProperFraction ( 1 , 0 ) , false ) ;
40+ assertEquals ( isProperFraction ( 0 , 0 ) , false ) ;
41+
42+ console . log ( isProperFraction ( 1 , 2 ) ) ;
43+ console . log ( isProperFraction ( 2 , 2 ) ) ;
44+ console . log ( isProperFraction ( 2 , 1 ) ) ;
45+ console . log ( isProperFraction ( 0 , 2 ) ) ;
46+ console . log ( isProperFraction ( 1 , 0 ) ) ;
47+ console . log ( isProperFraction ( 0 , 0 ) ) ;
0 commit comments