Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
remarcmij
left a comment
There was a problem hiding this comment.
Hi @Barboud , see my comments below with regard to Task 1. The code of that you originally submitted as your PR for me to review could never have worked because of the reasons I explained in Slack. I consider that a submission that was not tested by yourself.
| @@ -1,3 +1,65 @@ | |||
| export class Time { | |||
There was a problem hiding this comment.
It is best to define these constants outside of the class definition so that you can use them in all methods, not just the constructor.
| export class Time { | |
| const SECONDS_IN_MINUTE = 60; | |
| const SECONDS_IN_HOUR = SECONDS_IN_MINUTE * 60; | |
| const SECONDS_IN_DAY = SECONDS_IN_HOUR * 24; | |
| export class Time { |
| const SECONDS_IN_HOUR = 3600; | ||
| const SECONDS_IN_MINUTE = 60; |
There was a problem hiding this comment.
Use the suggested constants defined at the file level.
| const SECONDS_IN_HOUR = 3600; | |
| const SECONDS_IN_MINUTE = 60; |
| const totalSeconds = | ||
| hours * SECONDS_IN_HOUR + minutes * SECONDS_IN_MINUTE + seconds; | ||
|
|
||
| if (totalSeconds < 0 || totalSeconds >= 86400) { |
There was a problem hiding this comment.
86400 is a magic number.
| if (totalSeconds < 0 || totalSeconds >= 86400) { | |
| if (totalSeconds < 0 || totalSeconds >= SECONDS_IN_DAY) { |
| } | ||
|
|
||
| getHours() { | ||
| return Math.floor(this.#secondsFromMidnight / 3600); |
There was a problem hiding this comment.
| return Math.floor(this.#secondsFromMidnight / 3600); | |
| return Math.floor(this.#secondsFromMidnight / SECONDS_IN_HOUR); |
| } | ||
|
|
||
| getMinutes() { | ||
| return Math.floor((this.#secondsFromMidnight % 3600) / 60); |
There was a problem hiding this comment.
| return Math.floor((this.#secondsFromMidnight % 3600) / 60); | |
| return Math.floor((this.#secondsFromMidnight % SECONDS_IN_HOUR) / SECONDS_IN_MINUTE); |
| } | ||
|
|
||
| getSeconds() { | ||
| return this.#secondsFromMidnight % 60; |
There was a problem hiding this comment.
Check the rest of this class for magic number and replace them with the predefined constants.
| const myTime = new Time(12, 35, 0); | ||
| console.log(myTime.toString()); // 12:35:00 | ||
| myTime.getHours(); // 12 | ||
| myTime.getMinutes(); // 35 | ||
| myTime.getSeconds(); // 0 | ||
|
|
||
| myTime.addMinutes(25); | ||
| console.log(myTime.toString()); // 13:00:00 | ||
|
|
||
| myTime.addHours(12); | ||
| console.log(myTime.toString()); // 01:00:00 |
There was a problem hiding this comment.
To make this class reusable, this file should only define the class itself. These statements belong to the index.js file.
| const myTime = new Time(12, 35, 0); | |
| console.log(myTime.toString()); // 12:35:00 | |
| myTime.getHours(); // 12 | |
| myTime.getMinutes(); // 35 | |
| myTime.getSeconds(); // 0 | |
| myTime.addMinutes(25); | |
| console.log(myTime.toString()); // 13:00:00 | |
| myTime.addHours(12); | |
| console.log(myTime.toString()); // 01:00:00 |
📝 HackYourFuture auto gradeAssignment Score: 0 / 100 ✅Status: ✅ Passed Test Details |
Hi @remarcmij , I’ve updated the code for Task 1 and addressed the issues you mentioned. For task 2, I’ve also thoroughly tested it on my end to ensure everything is working correctly now. |
No description provided.