Skip to content

Commit 9b3b9f6

Browse files
committed
2-is-proper-function.js completed
1 parent a97de34 commit 9b3b9f6

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,7 +11,15 @@
1111
// execute the code to ensure all tests pass.
1212

1313
function isProperFraction(numerator, denominator) {
14-
// TODO: Implement this function
14+
// Non-unit fractions have a numerator that is more than 1, but less than the denominator.
15+
//Unit fractions all have a numerator of 1.
16+
17+
let validFraction = numerator < denominator && numerator > 0;
18+
if (validFraction) {
19+
return true;
20+
} else {
21+
return false;
22+
}
1523
}
1624

1725
// The line below allows us to load the isProperFraction function into tests in other files.
@@ -31,3 +39,9 @@ function assertEquals(actualOutput, targetOutput) {
3139

3240
// Example: 1/2 is a proper fraction
3341
assertEquals(isProperFraction(1, 2), true);
42+
assertEquals(isProperFraction(1, 5), true);
43+
assertEquals(isProperFraction(0, 4), false);
44+
assertEquals(isProperFraction(5, 5), false);
45+
assertEquals(isProperFraction(6, 5), false);
46+
assertEquals(isProperFraction(3, 5), true);
47+
assertEquals(isProperFraction(1, 0), false);

0 commit comments

Comments
 (0)