Skip to content

Shaghayegh F - #13

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.

@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 3 assignment! 🎉

The code is very clean and readable, showing a good grasp of modules and functions.

I've added a few inline comments across files, but they're mostly small tips and more advanced edge cases. The most important one is the date parsing that right now requires a trailing zero for the day and year (e.g. 8/9/2026 is not supported).

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/book.js
@@ -1,3 +1,11 @@
function isBookApplicable(searchString) {

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: what if someone callsisBookApplicable("") or isBookApplicable(" ")?

In JavaScript, "anything".includes("") evaluates to true, so this can be a nice real word edge case

Comment thread task-2/parse-date.js
Comment on lines +2 to +5
const format = dateString.substring(0, 3);
const first = dateString.substring(4, 6);
const second = dateString.substring(7, 9);
const year = dateString.substring(10, 14);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Because this splices the string based on specific positions, this works as long as the input string follows the expected pattern.

For instance: MDY 3-5-2025. The lack of a trailing 0 in the day will break the substring splice and lead to incorrect results. A possible way to make this more resilient would be to use .split(" ") to separate format from date, and then `.split("-") to separate the individual date components.

Comment thread task-4/cleanup.js
Comment on lines +32 to +35
console.log("Weather Report for " + cityName1);
console.log("Temperature: " + tempCelsius1 + "°C");
console.log("Temperature: " + tempFahrenheit1 + "°F");
console.log("Temperature: " + tempKelvin1 + "K");

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: this print block is repeated for 5 times, once per city/location. This is a situation where we could apply also apply the DRY principle by wrapping this into a reusable function!

Comment thread task-4/cleanup.js

}
// Temperature conversion and weather report for City 1
let cityName1 = "Amsterdam";

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: in Javscript, you can declare variables that are mutable via let or immutable via const. In general, if you don't need/expect it to mutate something (like the city name here) it is considered best practice to use const. That way you've that guarantee and it is clearer at a glance that it is a value that shouldn't mutate.

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