Skip to content

Commit d276533

Browse files
authored
2-is-proper-fraction.js
1 parent 1f0b098 commit d276533

File tree

1 file changed

+1
-50
lines changed

1 file changed

+1
-50
lines changed

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

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,9 @@ function isProperFraction(numerator, denominator) {
1111
if (numerator < denominator) {
1212
return true;
1313
}
14-
if (numerator < 0 && Math.abs(numerator) < denominator) {
15-
return false;
16-
}
17-
if (numerator >= denominator) {
18-
return false;
19-
}
20-
// we could add more checks here for invalid input, but not required for this exercise
2114
}
2215

23-
// The line below allows uscd-- to load the isProperFraction function into tests in other files.
16+
// The line below allows us to load the isProperFraction function into tests in other files.
2417
// This will be useful in the "rewrite tests with jest" step.
2518
module.exports = isProperFraction;
2619

@@ -54,55 +47,13 @@ assertEquals(improperFraction, false);
5447
// Explanation: The fraction -4/7 is a proper fraction because the absolute value of the numerator (4) is less than the denominator (7). The function should return true.
5548
const negativeFraction = isProperFraction(-4, 7);
5649
// ====> complete with your assertion
57-
assertEquals(negativeFraction, true);
5850

5951
// Equal Numerator and Denominator check:
6052
// Input: numerator = 3, denominator = 3
6153
// target output: false
6254
// Explanation: The fraction 3/3 is not a proper fraction because the numerator is equal to the denominator. The function should return false.
6355
const equalFraction = isProperFraction(3, 3);
6456
// ====> complete with your assertion
65-
assertEquals(equalFraction, false);
6657

6758
// Stretch:
6859
// What other scenarios could you test for?
69-
70-
71-
// Zero Numerator check:
72-
// Input: numerator = 0, denominator = 5
73-
// target output: true
74-
// Explanation: The fraction 0/5 is a proper fraction because the numerator (0) is less than the denominator (5). The function should return true.
75-
const zeroNumerator = isProperFraction(0, 5);
76-
assertEquals(zeroNumerator, true);
77-
78-
// Negative Denominator check:
79-
// Input: numerator = 2, denominator = -3
80-
// target output: false
81-
// Explanation: The fraction 2/-3 is not a proper fraction because the denominator is negative. The function should return false.
82-
const negativeDenominator = isProperFraction(2, -3);
83-
assertEquals(negativeDenominator, true);
84-
85-
let numerator= 1;
86-
let denominator= 7;
87-
console.log(numerator + "/" + denominator + " check =", isProperFraction(numerator, denominator));
88-
numerator= 5;
89-
denominator= 1;
90-
console.log(numerator + "/" + denominator + " check =", isProperFraction(numerator, denominator));
91-
numerator= -4;
92-
denominator= 9;
93-
console.log(numerator + "/" + denominator + " check =", isProperFraction(numerator, denominator));
94-
numerator= 0;
95-
denominator= 6;
96-
console.log(numerator + "/" + denominator + " check =", isProperFraction(numerator, denominator));
97-
numerator= 4;
98-
denominator= 4;
99-
console.log(numerator + "/" + denominator + " check =", isProperFraction(numerator, denominator));
100-
numerator= -5;
101-
denominator= 8;
102-
console.log(numerator + "/" + denominator + " check =", isProperFraction(numerator, denominator));
103-
numerator= 4;
104-
denominator= -2;
105-
console.log(numerator + "/" + denominator + " check =", isProperFraction(numerator, denominator));
106-
numerator= -3;
107-
denominator= -7;
108-
console.log(numerator + "/" + denominator + " check =", isProperFraction(numerator, denominator));

0 commit comments

Comments
 (0)