Manchester | ITP-Jan-26 | Ofonime Edak| Sprint 2 |Structuring and testing Data#1097
Manchester | ITP-Jan-26 | Ofonime Edak| Sprint 2 |Structuring and testing Data#1097Ofonimeedak wants to merge 8 commits intoCodeYourFuture:mainfrom
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
2 similar comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
cjyuan
left a comment
There was a problem hiding this comment.
Please note that in CYF courses, the recommended way to inform the reviewer of your changes is to do both of the following:
- Reply to their feedback.
- In the responses, clarify how each piece of feedback was addressed to demonstrate that you've carefully reviewed the suggestions.
- You may find the suggestions in this PR Guide useful.
- Your response may trigger a notification (depending on the reviewer's settings), helping ensure they’re aware of the updates you’ve made.
- In the responses, clarify how each piece of feedback was addressed to demonstrate that you've carefully reviewed the suggestions.
- Replace the "Reviewed" label by a "Needs review" label (which you have done -- great!)
- Without this label, the reviewer would not know if your changes is ready to be reviewed.
|
Thank you very much for your review. I can confirm now that I can spot the bugs after running more test cases. I will commit and resubmit ASAP |
|
Hi CJ, I have made the necessary change in my new commit. Please have a look. Thank you |
|
Added a padStart function to hours between 1 and 9 to ensure output consistency |
cjyuan
left a comment
There was a problem hiding this comment.
Code is working well. Good job.
| const hours = time.slice(0, 2); | ||
| const minutes = time.slice(3, 5); | ||
|
|
||
| if (Number(hours) > 12) { | ||
| let timeHour = Number(hours) - 12; |
There was a problem hiding this comment.
Why not convert hours to a number on line 6 once (instead of repeatedly convert it)?
If you need also hours as a string, you can use a separate variable to store hours as a number.
|
|
||
| if (Number(hours) > 12) { | ||
| let timeHour = Number(hours) - 12; | ||
| if (timeHour.toString().length !== 2) { |
There was a problem hiding this comment.
Could also check timeHour < 10.
| if (Number(hours) > 12) { | ||
| let timeHour = Number(hours) - 12; | ||
| if (timeHour.toString().length !== 2) { | ||
| timeHour = timeHour.toString().padStart(2, "0"); |
There was a problem hiding this comment.
timeHour was initially declared to stored a converted hour as a number, so it is a best practice not to reuse it to store a different kind of value. A better approach is to introduce a separate variable.
Self checklist
Changelist
I have followed the instructions and responded to the question to the best of my understanding
This PR covers debugging of function errors, testing, and structuring data