Skip to content

London | 26-ITP-Sep | Chandramani Gaire | Sprint 1 | Exhaustively test and fix formatAs12HourClock - #1649

Open
gaireprakash20-ops wants to merge 8 commits into
CodeYourFuture:mainfrom
gaireprakash20-ops:Sprint-1-coursework-of-data-structuring
Open

gaireprakash20-ops wants to merge 8 commits into
CodeYourFuture:mainfrom
gaireprakash20-ops:Sprint-1-coursework-of-data-structuring

Conversation

@gaireprakash20-ops

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

Changelist

I have completed the exercise as per the instructions provided.

@github-actions

This comment has been minimized.

@gaireprakash20-ops gaireprakash20-ops left a comment

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 did as per instruction

@gaireprakash20-ops gaireprakash20-ops 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 5, 2026

@abdishakoor-dev abdishakoor-dev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Your function gives the right answer for every valid time from 00:00 to 23:59, and your tests catch all three of the starter's bugs. Testing 23:05 to check single-digit minutes after noon was a good catch.

Three things before I can mark this Complete:

  1. A few exact boundaries have no test yet. See my comment on timeConverter.test.js line 13.
  2. timeConverter.js lines 1 to 16 still hold the old starter code in comments. See my comment there.
  3. timeConverter.test.js lines 32 to 39 are commented-out tests for inputs the README says you don't need to handle. See my comment there.

Add the Needs Review label again once you've pushed.

assert.equal(formatAs12HourClock("08:00"), "08:00 am");
});

test("can correctly convert midnight with double digit minutes", function () {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This tests a time inside the midnight hour, which is good. What about midnight itself, "00:00"? The same goes for noon, "12:00", and the very last minute of the day, "23:59". Bugs often hide at the exact point where something changes, so each of those is worth its own test.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All three are in now. Good.

@@ -1,11 +1,34 @@
function formatAs12HourClock(time) {
// This code only work when there is only hours not whenn there is minutes.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Git already keeps the starter version in your commit history, so this commented-out copy isn't needed. Please delete lines 1 to 16, and the comment on line 17 too if it no longer makes sense without them. The file should only hold the code that runs.

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.

Delete unused line

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Gone, and the file is much easier to read.

test("can correctly convert one hour after noon", function () {
assert.equal(formatAs12HourClock("13:00"), "01:00 pm");
});
// It's a failing case also we need to complete it

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The README says "You don't need to worry about invalid inputs (e.g. "25:00")". So these two tests aren't part of the task, and commented-out code should be removed rather than left in. Please delete lines 32 to 39.

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.

remove the unnecessary code

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Deleted. Good.

@abdishakoor-dev abdishakoor-dev 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. labels Oct 6, 2026

@gaireprakash20-ops gaireprakash20-ops left a comment

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 changed as per the review

@gaireprakash20-ops gaireprakash20-ops added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Oct 6, 2026

@abdishakoor-dev abdishakoor-dev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All sorted, marking it Complete. Well done.

@abdishakoor-dev abdishakoor-dev added Complete Volunteer to add when work is complete and all review comments have been addressed. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Oct 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Complete Volunteer to add when work is complete and all review comments have been addressed. 📅 Sprint 1 Assigned during Sprint 1 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants