-
-
Notifications
You must be signed in to change notification settings - Fork 266
West Midlands | ITP September 2025 | Jonathan Boahene | Sprint 2 | Module Structuring and Testing Data #825
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?
Conversation
|
|
||
| // You should call this function a number of times to check it works for different inputs | ||
|
|
||
| function toPounds(penceString) { |
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.
Good, clear function name.
| function toPounds(penceString) { | ||
| // Remove trailing 'p' and pad with zeros to ensure at least 3 digits | ||
| const pence = penceString | ||
| .substring(0, penceString.length - 1) |
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.
This is clever and handles edge cases very well.
| const pounds = pence.substring(0, pence.length - 2); | ||
| const pencePart = pence.substring(pence.length - 2).padEnd(2, "0"); | ||
| // Return formatted string | ||
| return `£${pounds}.${pencePart}`; |
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.
💡 Nice that you included the £ symbol directly.
| // `current output: ${currentOutput2}, target output: ${targetOutput2}` | ||
| // ); | ||
|
|
||
| function formatAs12HourClock(time) { |
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.
solid implementation
jaymes15
left a comment
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.
Nice One!
Learners, PR Template
Self checklist
Changelist
In this pull request I have added improved solutions and comprehensive tests for Sprint 2 of Module-Structuring-and-Testing-Data.
I refactored functions to handle edge cases and ensure correct formatting, such as converting 24-hour time strings to 12-hour clock format with am/pm.
The code now includes robust test cases for different input scenarios, including midnight, noon, single-digit hours, and times close to midnight and noon.
These changes enhance reliability and maintainability, making the code easier to understand and verify for a wide range of data inputs.
Questions
No questions at this point