11// Implement a function isProperFraction,
2- // when given two numbers, a numerator and a denominator, it should return true if
2+ // when given two numbers, a numerator and a denominator, returns true if
33// the given numbers form a proper fraction, and false otherwise.
44
5- // Assumption: The parameters are valid numbers (not NaN or Infinity ).
5+ // Assumption: The parameters are valid numbers (not NaN or infinity ).
66
7- // Note: If you are unfamiliar with proper fractions, please look up its mathematical definition .
7+ // Note: If you are unfamiliar with proper fractions, please look it up .
88
99// Acceptance criteria:
10- // After you have implemented the function, write tests to cover all the cases, and
10+ // After you have implemented the function, write tests to
1111// execute the code to ensure all tests pass.
1212
1313function isProperFraction ( numerator , denominator ) {
14- // TODO: Implement this function
14+ return Math . abs ( numerator ) < Math . abs ( denominator ) ;
1515}
1616
17- // The line below allows us to load the isProperFraction function into tests in other files.
18- // This will be useful in the "rewrite tests with jest" step.
17+ // The line below allows us to load the isProperFraction function into other files
18+ // This will be useful in the "rewrite tests with jest" step later
1919module . exports = isProperFraction ;
2020
2121// Here's our helper again
@@ -27,7 +27,11 @@ function assertEquals(actualOutput, targetOutput) {
2727}
2828
2929// TODO: Write tests to cover all cases.
30- // What combinations of numerators and denominators should you test ?
30+ // What combinations of numerators and denominators should be tested ?
3131
3232// Example: 1/2 is a proper fraction
3333assertEquals ( isProperFraction ( 1 , 2 ) , true ) ;
34+ assertEquals ( isProperFraction ( 2 , 1 ) , false ) ;
35+ assertEquals ( isProperFraction ( - 1 , 2 ) , true ) ;
36+ assertEquals ( isProperFraction ( 3 , 3 ) , false ) ;
37+
0 commit comments