Skip to content

London | 26-ITP-Sep | Diana Ausiejute | Sprint 2 |Implement and Rewrite Tests - #1672

Open
ausiejute wants to merge 9 commits into
CodeYourFuture:mainfrom
ausiejute:coursework/sprint-3-implement-and-rewrite
Open

ausiejute wants to merge 9 commits into
CodeYourFuture:mainfrom
ausiejute:coursework/sprint-3-implement-and-rewrite

Conversation

@ausiejute

Copy link
Copy Markdown

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

Task code

CYF-1059

Changelist

Wrote function implementations and tests in Node and Jest covering a variety of cases.

@ausiejute ausiejute added 📅 Sprint 2 Assigned during Sprint 2 of this module Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Oct 10, 2026
@dkrest1 dkrest1 self-assigned this Oct 11, 2026
@dkrest1
dkrest1 self-requested a review October 11, 2026 17:37
@dkrest1 dkrest1 added the Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. label Oct 11, 2026
// execute the code to ensure all tests pass.

export function getAngleType(angle) {
// TODO: Implement this function

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

What do you think happens when a function is declared twice, once at the top and again right inside itself without the inner one ever being called?

@ausiejute ausiejute Oct 12, 2026 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I had to have a read about it and it seems that the function would be redefined inside of itself resulting in the inner function being called instead, but only if it needed to be a recursive one. In this situation, it would look confusing, but would still do the intended job.
However, I think there might have been a misunderstanding with the diff. I only changed the function declaration/export style slightly, so the original declaration in red was replaced by the implementation in green; the function isn't declared twice. I wondered about this because a similar comment was added to another task (implement-isProperFraction) on a function that was also in the deleted code. Could you clarify if I'm missing something?

// execute the code to ensure all tests pass.

export function getAngleType(angle) {
// TODO: Implement this function

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

What happens if someone passes a non-number like "90" or null here? Should we add validation

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Good point. I did not take that into consideration. Passing a regular string would return an "invalid angle", but an empty one or null would not


// TODO: Write tests to cover all cases, including boundary and invalid cases.
// Example: Identify Right Angles

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Should we add tests for zero and negative numbers too, just to check how those boundary cases are handled

// execute the code to ensure all tests pass.

export function isProperFraction(numerator, denominator) {
// TODO: Implement this function

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Looks like this function is declared twice here. What do you think happens to that inner function since it's never called

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

In my 1st version, the one you've commented, I changed the function declaration/export style slightly and if you view the file it's more clear that the function has been declared once


// TODO: Write tests to cover all cases.
// What combinations of numerators and denominators should you test?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

What happens if the denominator is 0? Should we add a test case to see how the function handles that?

return "invalid";
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Is there any debug logging at the bottom of the file that we should remove before finalizing?

// execute the code to ensure all tests pass.

export function getCardValue(card) {
// TODO: Implement this function

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Just like the other files, this function is declared twice. What happens to the inner function since it isn't exported or called

cardRank == "10"
) {
return Number(cardRank);
} else {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The instructions above mention that an invalid card string should throw an error. How does returning the string "invalid" compare to throwing an error

) {
return Number(cardRank);
} else {
return "invalid";

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

What happens to the throw new Error statement right after return "invalid"; on line 57? Will that error ever actually be reached by the program?

throw new Error(`Expected a number followed by a suit, but got "${card}"`);
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Is there any debug logging (console.log) at the bottom of the file that we should remove before finalizing or committing our code?

// To learn how to test whether a function throws an error as expected in Jest,
// please refer to the Jest documentation:
// https://jestjs.io/docs/expect#tothrowerror
// -----number cards------

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

GREAT WORK HERE!
but notice how all the number card tests (2 through 9) follow the exact same pattern. Is there a built-in Jest feature (like test.each) we could use here to keep our tests DRY (Do not repeat yourself) and avoid repeating code

@dkrest1 dkrest1 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Great job working through these! Your logic and test coverage for edge cases and errors are really strong.

Before finalizing, just double-check for:

  1. Duplicate function declarations in your implementation files.

  2. Leftover debug logs (console.log) that can be removed.

DRY tests (like using test.each for repetitive test cases).

Thanks for sharing your progress, keep up the great work!

@dkrest1 dkrest1 added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Review in progress This review is currently being reviewed. This label will be replaced by "Reviewed" soon. labels Oct 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Reviewed Volunteer to add when completing a review with trainee action still to take. 📅 Sprint 2 Assigned during Sprint 2 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants