Conversation
📝 HackYourFuture auto gradeAssignment Score: 0 / 100 ✅Status: ✅ Passed Test Details |
| const titleOfbook ="The fundamentals of JavaScript"; | ||
|
|
||
| const titleLowerCase = titleOfbook.toLowerCase(); | ||
| return titleLowerCase.includes(searchString.trim().toLowerCase()); |
There was a problem hiding this comment.
It is good that you created a variable named titleLowerCase and assigned the logic to it. You could do the same for the search string. It is good practice to break logic into small chunks and assign them to variables so the code is more readable and easier for future developers to maintain. For example:
const normalizedBookTitle = bookTitle.toLowerCase();
const normalizedSearchString = searchString.trim().toLowerCase();
return normalizedBookTitle.includes(normalizedSearchString);
Also, what if I provide an empty string? Or what if I call the isBookApplicable function without a parameter? Or what if the search string has an extra space between words?
console.log(isBookApplicable(""));
console.log(isBookApplicable());
console.log(isBookApplicable("The fundamentals of JavaScript"));
That's why, in software engineering, it's very important to first consider all the requirements and error cases that need to be handled ("Error Handling").
| return { day, month, year }; | ||
| } else if (dateString.includes("DMY")) { | ||
| //Format: DD-MM-YYYY | ||
| const parts = dateString.split(" ")[1].split("-"); |
There was a problem hiding this comment.
Please pay attention to the DRY principle.
| const month = parts[1]; | ||
| const day = parts[0]; | ||
| const year = parts[2]; | ||
| return { day, month, year }; |
There was a problem hiding this comment.
Nice that you handled all the requirements except returning values as numbers.
| } | ||
| export function convertSecondsToMinutes(s){ | ||
| return s / 60; | ||
| } No newline at end of file |
There was a problem hiding this comment.
You implemented all the requirements. One improvement would be to make your parameter names clearer. Please try to avoid using single letters for naming while programming. It might be hard for future developers to understand the code. Try to use clear naming.
| console.log("Wind chill in " + cityName3 + ": " + windChill3.toFixed(2) + "°C"); No newline at end of file | ||
| weatherReport(cityName2, tempCelsius2, windSpeed2); | ||
| console.log("---"); | ||
| weatherReport(cityName3, tempCelsius3, windSpeed3); |
There was a problem hiding this comment.
You used clear variable names and clear function names. And you implemented reusable functions in accordance with the separation of concerns principle; each function is responsible for one thing. Well done!
Your logic is correct; however, the outputs of your functions do not match the original file.
No description provided.