Skip to content

Commit aca3a78

Browse files
committed
rewrite code and tests
1 parent dad46f3 commit aca3a78

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

Sprint-3/1-implement-and-rewrite-tests/implement/2-is-proper-fraction.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,14 @@
1111
// execute the code to ensure all tests pass.
1212

1313
function isProperFraction(numerator, denominator) {
14-
// TODO: Implement this function
14+
if (Math.abs(numerator / denominator) < 1) {
15+
return true;// if numerator is smaller than denominator - return true
16+
} else {
17+
return false;//return false if numerator if bigger that denominator
18+
}
1519
}
1620

21+
1722
// The line below allows us to load the isProperFraction function into tests in other files.
1823
// This will be useful in the "rewrite tests with jest" step.
1924
module.exports = isProperFraction;
@@ -31,3 +36,12 @@ function assertEquals(actualOutput, targetOutput) {
3136

3237
// Example: 1/2 is a proper fraction
3338
assertEquals(isProperFraction(1, 2), true);
39+
40+
// Example: 2/3 is a proper fraction
41+
assertEquals(isProperFraction(2, 3), true);
42+
43+
// Example: 4/2 is not a proper fraction
44+
assertEquals(isProperFraction(4, 2), false);
45+
46+
// Example: 4/4 is not a proper fraction
47+
assertEquals(isProperFraction(4, 4), false);

0 commit comments

Comments
 (0)