Conversation
📝 HackYourFuture auto gradeAssignment Score: 0 / 100 ✅Status: ✅ Passed Test Details |
sycons
left a comment
There was a problem hiding this comment.
Following were implemented:
- Setup & configure project ✅
- Create a transactions array ✅
- Implement required functions ✅
- Implement display requirements ✅
- Display summary report ✅
- Code quality ✅
Good job in implementing the requirements ⭐
There are some minor improvements that I have left more info about in the comments.
- Use ES Modules way.
- Remove invalid comments
- Use javascript statements like
for...of
| } | ||
| ]; | ||
|
|
||
| module.exports = transactions; |
There was a problem hiding this comment.
export default transactions; is more common to use than module.exports = transactions
The way you've done it is the older CommonJS Module way. The newer way is to use export which is ES Modules way.
More info on the history: https://www.w3schools.com/nodejs/nodejs_modules_esm.asp
| const transactions = require('./data.js'); | ||
| const chalk = require('chalk'); | ||
| function addTransaction(transaction) { | ||
| // TODO: Implement this function |
There was a problem hiding this comment.
Code clean up: Remove these TODO statements. Now that you have implemented the code, these are not relevant anymore.
| function getTotalIncome() { | ||
| // TODO: Implement this function | ||
| let total = 0; | ||
| for (let i = 0; i < transactions.length; i++) { |
There was a problem hiding this comment.
This for loop is perfectly fine and works. But you can also use the for...of loop as well. This makes the code more readable and removes the need to use a variable i to keep track of the index.
Learn more: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of
| // TODO: Implement this function | ||
| let total = 0; | ||
| //for(const transaction of transactions) | ||
| for (let i = 0; i < transactions.length; i++) { |
| function getTransactionsByCategory(category) { | ||
| // TODO: Implement this function | ||
| const result = []; | ||
| for (let i = 0; i < transactions.length; i++) { |
|
|
||
| for (let i = 0; i < transactions.length; i++) { | ||
| const transaction = transactions[i]; | ||
| const { id, type, description, amount, category } = transaction; |
| @@ -0,0 +1,4 @@ | |||
| const { printAllTransactions, printSummary } = require('./finance.js'); | |||
|
|
|||
| printAllTransactions(); | |||
There was a problem hiding this comment.
Although this is fine to use run.js as the entry point of the app, usually app.js is used as the entry point.
| console.log(chalk.bold(`Total Transactions : ${transactionCount}`)); | ||
| } | ||
|
|
||
| function removeTransaction(id) { |
There was a problem hiding this comment.
Well done on implementing a bonus challenge ⭐
No description provided.