Skip to content

Manchester | Monsur Abdulrahman | 26-ITP-Sep | Sprint 1 | Format-clock-edge-cases - #1725

Open
Monsur0001 wants to merge 4 commits into
CodeYourFuture:mainfrom
Monsur0001:format-clock-edge-cases
Open

Monsur0001 wants to merge 4 commits into
CodeYourFuture:mainfrom
Monsur0001:format-clock-edge-cases

Conversation

@Monsur0001

Copy link
Copy Markdown

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-1197

Changelist

I suggested edge cases and fixed the code to make sure the test cases pass

@Monsur0001 Monsur0001 added 📅 Sprint 1 Assigned during Sprint 1 of this module Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Oct 17, 2026
@hackertainment hackertainment 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 Oct 18, 2026

@hackertainment hackertainment 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.

The code generally looks ok to me. Just need to fix the missing test case. Thank you, and keep it up.

return `${hours - 12}:00 pm`;
const convertedHours = hours - 12;
// Add leading zero if convertedHours is a single digit
const formattedHours = convertedHours < 10 ? `0${convertedHours}` : convertedHours;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

While this produces a correct result, it would be a best practice to assign the same type of data to a variable (rather than leaving it to the JavaScript interpreter for type conversion), i.e. ? `0${convertedHours}` : `convertedHours`; so that both values are of the string type.

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 test cases you have included are:

  • 00:00 midnight
  • 12:00 noon
  • 01:30 single digit hour in the morning
  • 13:45 single digit hour in the afternoon
  • 23:00 double digits hour in the afternoon

It seems that there is still one case missing. Please add it back, thanks a lot.

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.

Thank you for taking your time to review my code, I have added the "double-digit hour in the afternoon" test case.

@hackertainment hackertainment Nov 11, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Good try, but please read the list of test cases carefully. Since you already have both single-digit and double-digit hour in the afternoon in your original tests, the one you have missed would not be in the afternoon anyway.

@hackertainment hackertainment 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 Oct 18, 2026
@Monsur0001 Monsur0001 added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. 📅 Sprint 1 Assigned during Sprint 1 of this module and removed 📅 Sprint 1 Assigned during Sprint 1 of this module labels Nov 11, 2026
@hackertainment

Copy link
Copy Markdown

Please refer to my new comment #1725 (comment) , thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. Reviewed Volunteer to add when completing a review with trainee action still to take. 📅 Sprint 1 Assigned during Sprint 1 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants