Skip to content

Sheffield | 26-ITP-Jan | Martha Ogunbiyi | Sprint 3 | coursework/sprint-3-implement-and-rewrite#1240

Open
marthak1 wants to merge 7 commits intoCodeYourFuture:mainfrom
marthak1:coursework/sprint-3
Open

Sheffield | 26-ITP-Jan | Martha Ogunbiyi | Sprint 3 | coursework/sprint-3-implement-and-rewrite#1240
marthak1 wants to merge 7 commits intoCodeYourFuture:mainfrom
marthak1:coursework/sprint-3

Conversation

@marthak1
Copy link

Learners, PR Template

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Changelist

  • Implemented functions and wrote test cases using jest

@marthak1 marthak1 added 📅 Sprint 3 Assigned during Sprint 3 of this module Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Module-Structuring-And-Testing-Data The name of the module. labels Mar 10, 2026
@Edu-Vin Edu-Vin added Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Mar 10, 2026
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should check the definition of a proper fraction again and see if your test case for negative numbers is correct expecially -3/8. I will advise you to use Match.abs()

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback! My implementation checks whether the value of the fraction is between 0 and 1, which is the standard mathematical definition of a proper fraction. Based on that definition:

-3/8 → -0.375 → not proper

-8/-3 → 2.66… → not proper

-3/-8 → 0.375 → proper

Using Math.abs() would treat negative fractions like -3/8 as proper, even though their value is negative. That’s why I didn’t use Math.abs(), and why my tests reflect the “between 0 and 1” definition. Happy to adjust if a different definition is expected.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first rule of a proper fraction is that the numerator is less than the denominator. Your solution will fail on most negative numbers. Reason why a proper fraction is when the absolute value of the numerator is less than the absolute value of the denominator. A proper fraction is always less than 1

Based on your code, let's consider the following examples
you are returning properFraction > 0 && properFraction < 1

-1/2 will return false because the division is -0.5, and it is not greater than 0. But this is wrong as the result is less than 1 and the first rule of numerator < denominator stands.

Same thing with -3/8.

You can check this for further info https://www.splashlearn.com/math-vocabulary/proper-fraction

Math.abs() helps you work with negative numbers.

You can do more research on it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for explaining! I understand now that you're using the definition based on absolute values. I’ll update my code and tests to use Math.abs() so it matches that approach.

test(`Should throw an error`, () => {
expect(() => {
getCardValue("♠9");
}).toThrow();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good. To take it further, add a test to see if the returned error message is what you are expecting.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the feedback . Would add further test to see what error messages they return.

@Edu-Vin Edu-Vin added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Mar 10, 2026
@Edu-Vin
Copy link

Edu-Vin commented Mar 11, 2026

Your recent commits added a solution for 2-practice-tdd. The Readme file for Sprint-3 says 1 pull request per directory, so 2-practice-tdd is supposed to have its own pull request.

@marthak1 marthak1 closed this Mar 11, 2026
@marthak1 marthak1 reopened this Mar 11, 2026
@github-actions
Copy link

The changed files in this PR don't match what is expected for this task.

Please check that you committed the right files for the task, and that there are no accidentally committed files from other sprints.

Please review the changed files tab at the top of the page, we are only expecting changes in this directory: ^Sprint-3/1-implement-and-rewrite-tests/

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

If this PR needs reviewed, please add the 'Needs Review' label to this PR after you have resolved the issues listed above.

@marthak1 marthak1 closed this Mar 11, 2026
@marthak1 marthak1 reopened this Mar 11, 2026
@github-actions
Copy link

The changed files in this PR don't match what is expected for this task.

Please check that you committed the right files for the task, and that there are no accidentally committed files from other sprints.

Please review the changed files tab at the top of the page, we are only expecting changes in this directory: ^Sprint-3/1-implement-and-rewrite-tests/

If this PR is not coursework, please add the NotCoursework label (and message on Slack in #cyf-curriculum or it will probably not be noticed).

If this PR needs reviewed, please add the 'Needs Review' label to this PR after you have resolved the issues listed above.

@marthak1 marthak1 force-pushed the coursework/sprint-3 branch from 17cc045 to 06520c4 Compare March 11, 2026 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Module-Structuring-And-Testing-Data The name of the module. Reviewed Volunteer to add when completing a review with trainee action still to take. 📅 Sprint 3 Assigned during Sprint 3 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants