Skip to content

Commit f54aa1f

Browse files
authored
Implement isProperFraction function and add tests
Implemented the isProperFraction function to check if the numerator is less than the denominator. Added tests for various cases including proper fractions, improper fractions, and edge cases.
1 parent dfdbad9 commit f54aa1f

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

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

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,16 @@
1111
// execute the code to ensure all tests pass.
1212

1313
function isProperFraction(numerator, denominator) {
14-
// TODO: Implement this function
14+
if (numerator < denominator) {
15+
return true;
16+
} else {
17+
return false;
18+
}
1519
}
20+
module.exports = isProperFraction;
1621

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.
19-
module.exports = isProperFraction;
2024

2125
// Here's our helper again
2226
function assertEquals(actualOutput, targetOutput) {
@@ -31,3 +35,16 @@ function assertEquals(actualOutput, targetOutput) {
3135

3236
// Example: 1/2 is a proper fraction
3337
assertEquals(isProperFraction(1, 2), true);
38+
//Test
39+
// Proper fraction 3/5
40+
assertEqual(isproperFraction(3,5), true);
41+
assertEual(isProperFraction(4/8), true);
42+
43+
//Not
44+
assertEqual(isproperFraction(9,7),false);
45+
assertEqual(isproperFracton(13/11),false);
46+
47+
//Edge case
48+
assertEqual(isperoperFractio(0,5),true);
49+
50+

0 commit comments

Comments
 (0)