Repository navigation
Shaghayegh F - #13
Shaghayegh F#13shaghayegh11297 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
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!
| @@ -1,3 +1,11 @@ | |||
| function isBookApplicable(searchString) { | |||
There was a problem hiding this comment.
Bonus: what if someone callsisBookApplicable("") or isBookApplicable(" ")?
In JavaScript, "anything".includes("") evaluates to true, so this can be a nice real word edge case
| const format = dateString.substring(0, 3); | ||
| const first = dateString.substring(4, 6); | ||
| const second = dateString.substring(7, 9); | ||
| const year = dateString.substring(10, 14); |
There was a problem hiding this comment.
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.
| console.log("Weather Report for " + cityName1); | ||
| console.log("Temperature: " + tempCelsius1 + "°C"); | ||
| console.log("Temperature: " + tempFahrenheit1 + "°F"); | ||
| console.log("Temperature: " + tempKelvin1 + "K"); |
There was a problem hiding this comment.
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!
|
|
||
| } | ||
| // Temperature conversion and weather report for City 1 | ||
| let cityName1 = "Amsterdam"; |
There was a problem hiding this comment.
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.
No description provided.