Skip to content

c56 week 2 task-1 - #18

Open
someykoku wants to merge 1 commit into
HackYourAssignment:mainfrom
someykoku:task-1
Open

someykoku wants to merge 1 commit into
HackYourAssignment:mainfrom
someykoku:task-1

Conversation

@someykoku

Copy link
Copy Markdown

No description provided.

@RHSebregts RHSebregts left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hi!

Thank you for this first task. There's a small issue regarding 0 and its leap year status. And a small grammar nitpick.

Also, even though small PR's are always recommended, putting every task in a separate PR might be slightly overdoing it. But at least you got some practice in making PR's and using git, so maybe it's a good thing?

Comment thread task-1/leap-year.js
} else if (year <=1 || year >= 9999) {
console.log(`${year} Invalid year!`)
} else {
console.log(`${year} is not the leap year!`);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

THE leap year, or a leap year? 🤔

Comment thread task-1/leap-year.js

let year = Number(prompt('Enter the year: '));

function CheckLeapYear(year) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Really like this standalone function, which we can then use for the checks. That's a great pattern.

Comment thread task-1/leap-year.js
Comment on lines +14 to +22
if (year % 400 === 0) {
return true;
} else if (year % 100 === 0) {
return false;
} else if (year % 4 === 0) {
return true;
} else {
return false
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Since you are using return you can use my all time favourite pattern for readable code: the early escape. That way we can get rid of all the else if statements. That's not a requirement, but a very nice pattern to use whenever you can to make your code nice and easy to read.

Comment thread task-1/leap-year.js
}

if (CheckLeapYear(year)) {
console.log(`${year} is a leap year!`);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

So, what about 0? Is that a leap year?

@RHSebregts RHSebregts added Reviewed This assignment has been reivewed by a mentor and a feedback has been provided and removed Review in progress labels Nov 18, 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