Conversation
📝 HackYourFuture auto gradeAssignment Score: 0 / 100 ✅Status: ✅ Passed Test Details |
| #secondsFromMidnight; | ||
|
|
||
| constructor(hours, minutes, seconds) { | ||
| const total = hours * 3600 + minutes * 60 + seconds; |
There was a problem hiding this comment.
Very well done, it is smart to make everything in seconds
| } | ||
|
|
||
| getMinutes() { | ||
| return Math.floor((this.#secondsFromMidnight % 3600) / 60); |
|
|
||
| addSeconds(seconds) { | ||
| this.#secondsFromMidnight = | ||
| (((this.#secondsFromMidnight + seconds) % 86400) + 86400) % 86400; |
There was a problem hiding this comment.
Very good use of the modulo %, you handle all the edges cases
| const h = String(this.getHours()).padStart(2, "0"); | ||
| const m = String(this.getMinutes()).padStart(2, "0"); | ||
| const s = String(this.getSeconds()).padStart(2, "0"); | ||
| return `${h}:${m}:${s}`; |
| console.log(`\nQuestion ${index + 1}: ${q.question}`); | ||
|
|
||
| // Loop through each option and print it with a number | ||
| q.options.forEach((opt, i) => { |
|
|
||
| // \x1b[32m means green, \x1b[0m resets the colour back to normal | ||
| export function printCorrect() { | ||
| console.log("\x1b[32m✓ Correct! +1 point\x1b[0m"); |
|
|
||
| export function printWrong(correct, options) { | ||
| console.log( | ||
| `\x1b[31m✗ Wrong! The correct answer was ${correct}: ${options[correct - 1]}\x1b[0m`, |
| let score = 0; | ||
|
|
||
|
|
||
| for (let i = 0; i < questions.length; i++) { |
|
|
||
| const answer = parseInt(input); | ||
|
|
||
| if (answer === q.correct) { |
JQnetherlands
left a comment
There was a problem hiding this comment.
Hello Hannah,
Congratulations, you have passed successfully the task 1 and task 2.
The task 1 is very nicely implemented, the class that you created is very strong and solid, I applause how you decide to make everything seconds, that indeed make it everything easier, and in every step you show you understand about the modulo and how you can use it to get the hours, minutes and seconds, the modulo is a very good trick to know in javaScript. You use the # well.
About the second task, your code works well , I mocked the fetch question with my own mockQuestions.js, cos I at the moment I don’t have a credit card to get a free API key, I trust that you tried your code with your own API Key.
I applause your implementation of the class in task1 , if one day you start to learn java you will see that your knowledge about creating a solid base class will help you with Java.
Keep the good Work! I wish you success in every instance of your career!
No description provided.