Skip to content

Conversation

@YanaP1312
Copy link

  1. Added a check for a leap year (task-1);
  2. Added logic for fn to login.js (task-2);
  3. Fixed converter & added feature (task-3).

@mo92othman mo92othman self-assigned this Jan 24, 2026
Copy link

@mo92othman mo92othman left a comment

Choose a reason for hiding this comment

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

Hi @YanaP1312 ! Thanks for submitting the assignment! Nice job on this assignment! You completed all three tasks successfully, well done!

I’ve left a few small comments to keep in mind for future improvements. Let me know if anything is unclear.

// Step 1: prompt the user to enter a year
// Step 2: convert the user input to a number so we can perform calculations
// Step 3: Implement the logic
if (year < 1 || year > 9999) {

Choose a reason for hiding this comment

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

This condition validates the year range correctly.
However, if the user enters text instead of a number, Number() returns NaN, and this check doesn’t catch it. That’s why the program prints Yes, NaN is a leap year.

Could you think of a way to improve this check?

// Step 3: Implement the logic
if (year < 1 || year > 9999) {
console.log("Invalid year!");
} else if (!(year % 400) || (!(year % 4) && (year % 100))) {

Choose a reason for hiding this comment

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

Nice job, this condition correctly covers all the leap year rules!

For readability, you could consider writing the logic in a more easier to read way.

Another possibility is assigning it to a variable like isLeapYear. This would make the code easier to read and avoid repeating logic in the future. This is an optional improvement to keep in mind.

const isLeapYear = (year % 4 === 0) && (year % 100 !== 0 || year % 400 === 0);

if (isLeapYear) {
  console.log(`Yes, ${year} is a leap year`);
} else {
  console.log(`No, ${year} is not a leap year`);
}

if (incorrectAttempts > 3) {
errorMessage("Login blocked: Too many incorrect attempts");
return;
} else if (isValid) {

Choose a reason for hiding this comment

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

Nice that you used a boolean (isValid), this makes more readable 👍

errorMessage("Login blocked: Too many incorrect attempts");
return;
} else if (isValid) {
incorrectAttempts = 0;

Choose a reason for hiding this comment

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

Nice, resetting incorrectAttempts after a successful login is a good idea, but it wasn’t required in the task instructions. For the future, whenever you add extra things, check if the behavior is expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants