Skip to content

Shaghayegh F. - #12

Open
shaghayegh11297 wants to merge 1 commit into
HackYourAssignment:mainfrom
shaghayegh11297:main
Open

shaghayegh11297 wants to merge 1 commit into
HackYourAssignment:mainfrom
shaghayegh11297:main

Conversation

@shaghayegh11297

Copy link
Copy Markdown

No description provided.

@shaghayegh11297 shaghayegh11297 changed the title Complete week 2 assignment: leap year, login, converter Shaghayegh F. Nov 11, 2026

@Naraujo13 Naraujo13 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.

Hey!

Great job on the Week 2 assignment! 🎉

Your code is super clean, readable, and shows a really solid grasp of conditionals, boolean logic, and working with user inputs.

The !Number.isInteger() in Task 1 and splitting out the checks into readable variables in Task 2 were really nice touches!

I've added a few inline comments across files, but they're mostly small tips and more advanced edge cases.

Feel free to reply here or reach out in Slack if you have any questions about the comments. Keep up the great work!

Comment thread task-1/leap-year.js
if (!Number.isInteger(year) || year < 1 || year > 9999) {
console.log('Invalid year!');
} else if (year % 400 === 0 || (year % 4 === 0 && year % 100 !== 0)) {
console.log('Yes, ' + 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.

Spotless script!

A bonus suggestion to explore: an alternative to string interpolation are string literals.
For instance you could do the equivalent here with:

console.log(`Yes, ${year} is a leap year`)

Comment thread task-2/login.js
errorMessage('Login blocked: Too many incorrect attempts');
return;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Very nice script!

Bonus: what happens if a user got their password wrong two times and then logged in successfully? Should we reset the incorrect attempts? How could we do that?

Comment thread task-3/converter.js
if (menuSelection === "1") {
// EUR to USD
const eurAmountInput = prompt("Enter amount in EUR: ");
const eurAmountNum = Number(eurAmountInput);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bonus: If I hit just enter in this input we'll call Number("") on an empty string we'll get unintended side effects due to empty string being converted to 0 in JS. How can we avoid this edge case?

Comment thread task-2/login.js
// Write your code here.
// Use the variables 'username' and 'password' to access the input values
// Use incorrectAttempts to track the number of failed attempts
if (incorrectAttempts > 3) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bonus: Technically right now I can attempt more than 4 times before I am blocked - I was able to get 5 attempts! Try tracing back how many attempts and how the counter changes since it is incremented at the end of the script.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants