Repository navigation
Shaghayegh F. - #12
shaghayegh11297 wants to merge 1 commit into
Conversation
Naraujo13
left a comment
There was a problem hiding this comment.
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!
| 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'); |
There was a problem hiding this comment.
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`)
| errorMessage('Login blocked: Too many incorrect attempts'); | ||
| return; | ||
| } | ||
|
|
There was a problem hiding this comment.
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?
| if (menuSelection === "1") { | ||
| // EUR to USD | ||
| const eurAmountInput = prompt("Enter amount in EUR: "); | ||
| const eurAmountNum = Number(eurAmountInput); |
There was a problem hiding this comment.
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?
| // 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) { |
There was a problem hiding this comment.
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.
No description provided.