11function isProperFraction ( numerator , denominator ) {
2- if ( numerator < denominator ) return true ;
3- // add your completed function from key-implement here
2+ if ( denominator === 0 ) return false ; // Avoid division by zero
3+ if ( numerator < 0 || denominator < 0 ) return false ; // Proper fractions are positive
4+ if ( numerator < denominator ) return true ; // Proper if numerator < denominator
5+ return false ; // Otherwise, it's improper
46}
57
6- module . exports = isProperFraction ;
8+ module . exports = isProperFraction ;
9+ // Test cases for the isProperFraction function
10+ console . log ( isProperFraction ( 1 , 2 ) ) ; // true
11+ console . log ( isProperFraction ( 3 , 4 ) ) ; // true
12+ console . log ( isProperFraction ( 5 , 5 ) ) ; // false
13+ console . log ( isProperFraction ( 7 , 6 ) ) ; // false
14+ console . log ( isProperFraction ( 0 , 1 ) ) ; // true
15+ console . log ( isProperFraction ( 1 , 0 ) ) ; // false (denominator is zero)
16+ console . log ( isProperFraction ( - 1 , 2 ) ) ; // false (negative numerator)
17+ console . log ( isProperFraction ( 1 , - 2 ) ) ; // false (negative denominator)
18+ console . log ( isProperFraction ( - 1 , - 2 ) ) ; // false (both negative)
19+ console . log ( isProperFraction ( 2 , 3 ) ) ; // true
0 commit comments