Repository navigation
Conversation
Naraujo13
left a comment
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. The refactoring on task 4 especially is spot on and applies DRY principles very well!
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!
| // Your code here | ||
| const prompt = require("prompt-sync")(); | ||
| const bookName = "the fundamentals of javascript"; | ||
| let isApplicable; |
There was a problem hiding this comment.
A best practice is to keep variables from a given function scoped to it. Here this means moving this declaration to inside the isBookApplicable function.
That allows us to keep the isApplicable variable isolated to the function and to each invocation.
| const bookName = "the fundamentals of javascript"; | ||
| let isApplicable; | ||
| function isBookApplicable(book) { | ||
| book = book.toLowerCase().trim(); |
There was a problem hiding this comment.
Bonus: usually a best practice when manipulating parameters inside a function is to avoid reassigning them, instead declaring a new variable and assigning to it. This helps improve readability and avoid side effects of potentially modifying the parameter.
e.g. const cleanBook = book.toLowerCase().trim().
|
|
||
| let dateFormat = dateString.split(" ")[0].toLowerCase().trim(); | ||
| let date = dateString.split(" ")[1]; | ||
| const dateParts = date.split(/[\/\-\.]/).map(Number); //coz user might separate differently |
| 0.3965 * temp * Math.pow(windSpeed, 0.16); | ||
| return windChill.toFixed(2); | ||
| } | ||
| function showWeather(city, temp, windSpeed) { |
There was a problem hiding this comment.
Great to see the logging modularised into a reusable function!
No description provided.