Skip to content

ZA | MAY-2025 | Shannon Davids | Sprint-3 | Module-Structuring-and-Testing-Data #616

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
is proper fraction
  • Loading branch information
Shannon-Davids committed Jun 24, 2025
commit 3e6f5699280116e2fc15d75bfb6244e6e2e5804c
15 changes: 11 additions & 4 deletions Sprint-3/1-key-implement/2-is-proper-fraction.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@
// write one test at a time, and make it pass, build your solution up methodically

function isProperFraction(numerator, denominator) {
if (numerator < denominator) return true;
if (numerator < denominator) {
return true;
} else if (numerator >= denominator) {
return false;
} else if (numerator === 1) {
return true;
}
}

// here's our helper again
function assertEquals(actualOutput, targetOutput) {
console.assert(
Expand Down Expand Up @@ -41,13 +46,15 @@ assertEquals(improperFraction, false);
// 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.
const negativeFraction = isProperFraction(-4, 7);
// ====> complete with your assertion

assertEquals(negativeFraction, true);
// Equal Numerator and Denominator check:
// Input: numerator = 3, denominator = 3
// target output: false
// Explanation: The fraction 3/3 is not a proper fraction because the numerator is equal to the denominator. The function should return false.
const equalFraction = isProperFraction(3, 3);
// ====> complete with your assertion

assertEquals(equalFraction, false);
// Stretch:
// What other scenarios could you test for?
const unitFraction = isProperFraction(1, 9);
assertEquals(unitFraction, true);