Conversation
YanaP1312
commented
Feb 4, 2026
- All required functions for the financial tracker have been implemented.
- Repeated logic has been extracted into separate helper functions (for example, expense filtering).
- A bonus task function has been added.
- A multi‑line comment has been written for the most complex function (findConsecutiveExpensiveMonth).
This comment has been minimized.
This comment has been minimized.
reposman33
left a comment
There was a problem hiding this comment.
looks good, but I don't see (a dependency on) prettier in package.json
| "author": "", | ||
| "license": "ISC", | ||
| "dependencies": { | ||
| "chalk": "^4.1.2" |
There was a problem hiding this comment.
I had only a .prettierrc file before, but Prettier wasn’t installed as a project dependency.
I’ve now added Prettier to devDependencies, created a .prettierignore file, and added a format script ("format": "prettier --write ."). Formatting is now handled consistently across the project.
package.json
Outdated
| "main": "index.js", | ||
| "scripts": { | ||
| "test": "echo \"Error: no test specified\" && exit 1", | ||
| "start": "node finance-tracker/app.js" |
There was a problem hiding this comment.
nice touch to add a script for starting the app
reposman33
left a comment
There was a problem hiding this comment.
looks good, 2 comments on the new (2023) toSorted() function and a performance optimization tip
finance-tracker/finance.js
Outdated
| const largestExpense = getLargestExpense(transactions); | ||
| const largestExpenseForm = chalk.bold(largestExpense.amount); | ||
| const largestExpenseDescr = getFirstCharacterToUp(largestExpense.description); | ||
| ? chalk.bold.cyan(getBalance(transactions)) |
There was a problem hiding this comment.
you execute 3 times the same function getBalance(transactions), which is 2 times too much. Better is to store the value of getBalance(transactions) in a variable and then use that variable to check if its value > 0 and then passing it to chalk.bold.cyan() or chalk.bold.red()
There was a problem hiding this comment.
Thanks for pointing this out!
I refactored the code and now store the result of getBalance(transactions) in a variable instead of calling the function multiple times. The updated version is already pushed.
|
|
||
| export function searchTransactionsByDate(transactions, startDate, endDate) { | ||
| const sorted = transactions | ||
| .slice() |
There was a problem hiding this comment.
FYI: there is now an Array.toSorted() function that doesn't mutate the array but returns a new sorted array
There was a problem hiding this comment.
Thanks! I tried using toSorted(), but my Node version (18.x) doesn’t support it yet, so I switched back to .slice().sort(), which works correctly.
📝 HackYourFuture auto gradeAssignment Score: 0 / 100 ✅Status: ✅ Passed Test Details |