We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 088f2bd commit cc10398Copy full SHA for cc10398
Sprint-3/1-implement-and-rewrite-tests/implement/2-is-proper-fraction.js
@@ -12,6 +12,16 @@
12
13
function isProperFraction(numerator, denominator) {
14
// TODO: Implement this function
15
+ if (denominator === 0) {
16
+ return false;
17
+ }
18
+ if (numerator < 0 && denominator < 0) {
19
+ return Math.abs(numerator) < Math.abs(denominator);
20
21
+ if (numerator < 0 || denominator < 0) {
22
23
24
+ return numerator < denominator;
25
}
26
27
// The line below allows us to load the isProperFraction function into tests in other files.
@@ -31,3 +41,10 @@ function assertEquals(actualOutput, targetOutput) {
31
41
32
42
// Example: 1/2 is a proper fraction
33
43
assertEquals(isProperFraction(1, 2), true);
44
+assertEquals(isProperFraction(2, 1), false);
45
+assertEquals(isProperFraction(0, 1), true);
46
+assertEquals(isProperFraction(-1, 2), false);
47
+assertEquals(isProperFraction(1, -2), false);
48
+assertEquals(isProperFraction(-1, -2), false);
49
+assertEquals(isProperFraction(3, 4), true);
50
+assertEquals(isProperFraction(4, 3), false);
0 commit comments