Skip to content

Pavel T#4

Open
pavel-tisner wants to merge 3 commits intoHackYourAssignment:mainfrom
pavel-tisner:main
Open

Pavel T#4
pavel-tisner wants to merge 3 commits intoHackYourAssignment:mainfrom
pavel-tisner:main

Conversation

@pavel-tisner
Copy link
Copy Markdown

No description provided.

@remarcmij remarcmij self-assigned this Mar 25, 2026
@remarcmij
Copy link
Copy Markdown

I will review your PR after you have added task 2.

@github-actions
Copy link
Copy Markdown

📝 HackYourFuture auto grade

Assignment Score: 0 / 100 ✅

Status: ✅ Passed
Minimum score to pass: 0
🧪 The auto grade is experimental and still being improved

Test Details

@pavel-tisner
Copy link
Copy Markdown
Author

I will review your PR after you have added task 2.
Task-2 has been added. Ready to review

Copy link
Copy Markdown

@remarcmij remarcmij left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @pavel-tisner, everything works fine, but the implementation of both tasks could be improved. Please see my comments below.

this.#secondsFromMidnight = hours * 3600 + minutes * 60 + seconds;
this.hours = hours;
this.minutes = minutes;
this.seconds = seconds;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not very clear which variable(s) represent the "single source of truth" of the time value. The class encapsulates the time as a number of seconds as well as an hours, minutes and seconds value. Moreover, the #secondsFromMidnight property is made private, while the hours, minutes and seconds properties are public despite the fact that there are "getter" methods for these values.

It would be clearer to have a single private property, #secondsFromMidnight, to represent the time value and compute the hours, minutes, and seconds on the fly in the "getter" methods.

}

getHours() {
return this.hours;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than maintaining a separate class property for the hours value, you can simply compute the value using integer arithmetic from the #secondsFromMidnight property.

}

getMinutes() {
return this.minutes;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

}

getSeconds() {
return this.seconds;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here

return this.seconds;
}

#normilized() {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: spelling error -> normalized

Comment on lines +39 to +41
${chalk.blue(result.question)}
${result.answers.map((answer, i) => `${i + 1}. ${answer}`).join("\n")}
`);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To maintain correct indentation you could refactor this as:

Suggested change
${chalk.blue(result.question)}
${result.answers.map((answer, i) => `${i + 1}. ${answer}`).join("\n")}
`);
console.log(
`\n${chalk.blue(result.question)}\n${result.answers
.map((answer, i) => `${i + 1}. ${answer}`)
.join("\n")}`,
);

import { BASE_PROMPT } from "./basePrompt.js";
import {userAnswer, isValidAnswer} from "./utils.js"

const prompt = promptSync();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A user who wants to break off the quiz should either be able to press Ctrl-C or you should provide a menu option (say, x) to exit the quiz prematurely. The sigint option below enables Ctrl-C.

Suggested change
const prompt = promptSync();
const prompt = promptSync({ sigint: true });

prompt("Press enter to start the game");

const score = {
totalQuestions: 10,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This property is never mutated. It might as well have been a const, e.g.

const TOTAL_QUESTIONS = 10;

totalQuestions: 10,
currentQuestion: 1,
correctAnswers: 0,
wrongAnswers: 0,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This property is updated but never reported. It serves no purpose.

});

async function app() {
try {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 for handling errors

@remarcmij remarcmij added the Reviewed This assignment has been reivewed by a mentor and a feedback has been provided label Mar 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Reviewed This assignment has been reivewed by a mentor and a feedback has been provided

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants