Skip to content

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

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

Monsur0001 wants to merge 3 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.

@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
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 1 Assigned during Sprint 1 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants