File tree Expand file tree Collapse file tree
Sprint-3/1-implement-and-rewrite-tests Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1111// execute the code to ensure all tests pass.
1212
1313function isProperFraction ( numerator , denominator ) {
14- // TODO: Implement this function
14+ if ( denominator === 0 ) {
15+ return false
16+ }
17+
18+ if ( numerator === denominator ) {
19+ return false
20+ }
21+
22+ if ( numerator > denominator ) {
23+ return false
24+ }
25+
26+ if ( numerator < denominator ) {
27+ return true
28+ }
1529}
1630
31+ // function isProperFraction(numerator, denominator) {
32+ // if (denominator === 0) {
33+ // return false
34+ // } else if (Math.abs(numerator) < Math.abs(denominator)) {
35+ // return true
36+ // };
37+ // }
1738// The line below allows us to load the isProperFraction function into tests in other files.
1839// This will be useful in the "rewrite tests with jest" step.
1940module . exports = isProperFraction ;
Original file line number Diff line number Diff line change @@ -8,3 +8,20 @@ const isProperFraction = require("../implement/2-is-proper-fraction");
88test ( `should return false when denominator is zero` , ( ) => {
99 expect ( isProperFraction ( 1 , 0 ) ) . toEqual ( false ) ;
1010} ) ;
11+
12+ // numerator is higher than denominator
13+ test ( `should return false when numerator is higher value than denominator` , ( ) => {
14+ expect ( isProperFraction ( 2 , 1 ) ) . toEqual ( false ) ;
15+ } ) ;
16+
17+ // numerator is lower than denominator
18+ test ( `should return true when numerator is lower value than denominator` , ( ) => {
19+ expect ( isProperFraction ( 1 , 2 ) ) . toEqual ( true ) ;
20+ expect ( isProperFraction ( - 1 , 2 ) ) . toEqual ( true ) ;
21+ expect ( isProperFraction ( 0 , 2 ) ) . toEqual ( true ) ;
22+ } )
23+
24+ // numerator is equal to denominator
25+ test ( `should return false when numerator is equal to denominator` , ( ) => {
26+ expect ( isProperFraction ( 1 , 1 ) ) . toEqual ( false ) ;
27+ } ) ;
You can’t perform that action at this time.
0 commit comments