Repository navigation
Cape Town | sep-2026-ITP | Matthaus Bause | Sprint 1 | Time Clock #1648
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
2ec464d
0795731
7753fc4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,23 @@ | ||
| function formatAs12HourClock(time) { | ||
|
|
||
| const [hoursStr, minutesStr] = time.split(':'); | ||
| const hours = Number(hoursStr); | ||
| const minutes = minutesStr; | ||
|
|
||
| const hours = Number(time.slice(0, 2)); | ||
| if (hours === 0 || hours === 24) { | ||
| return `12:${minutes} am` | ||
| } | ||
|
|
||
| if (hours === 12) { | ||
| return `12:${minutes} pm` | ||
| } | ||
|
|
||
| if (hours > 12) { | ||
| return `${hours - 12}:00 pm`; | ||
| return `${hours - 12}:${minutes} pm`; | ||
| } | ||
| return `${time} am`; | ||
|
|
||
| const formattedHours = String(hours).padStart(2, '0'); | ||
| return `${formattedHours}:${minutes} am`; | ||
| } | ||
|
|
||
| export {formatAs12HourClock}; | ||
| export {formatAs12HourClock}; |
|
cjyuan marked this conversation as resolved.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you check whether the expected return values specified in the tests use a consistent format? When a function's return values are not consistently formatted, it can lead to unintended side effects. For examples:
For this reason, it would be better to ensure that the function always returns values in a consistent format. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not all statements are terminated by a semicolon and spacing around
{and '}` is not fully consistent.Suggestion:
Resource: Visual Studio Code - Formatting