Skip to content

Conversation

@Barboud
Copy link

@Barboud Barboud commented Feb 3, 2026

No description provided.

@github-actions
Copy link

github-actions bot commented Feb 3, 2026

📝 HackYourFuture auto grade

Assignment Score: 0 / 100 ✅

Status: ✅ Passed
Minimum score to pass: 0
🧪 The auto grade is experimental and still being improved

Test Details

@mo92othman mo92othman self-assigned this Feb 5, 2026
Copy link

@mo92othman mo92othman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @Barboud! Overall, good work 👍
The logic is clear, and the application works as expected. I have left some small comments.

One small setup note: project configuration files (package.json, .gitignore``, Prettier config) are required to be placed inside the project folder itself ( finance-tracker) as the assignments ask for that. Then you needed to create `.gitignore` for `node_modules/`

Comment on lines +4 to +10
export function addTransaction(transaction) {
if (!transaction[0].id) {
transaction[0].id = transactions.length + 1;
}
transactions.push(...transaction);
return transactions;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see this function expects an array of transactions, but the assignment goal is to add one transaction at a time.

What you wrote is correct, but since the function (by its name) adds a single transaction, we could simplify it to accept one transaction object instead.

Comment on lines +46 to +57
export function getLargestExpense() {
const filteredTransactions = getTransactionsByType('expense');
let largestTransaction = [];
let largestExpense = null;
for (const filteredTransaction of filteredTransactions) {
if (filteredTransaction.amount > largestExpense) {
largestExpense = filteredTransaction.amount;
largestTransaction.pop(filteredTransaction);
largestTransaction.push(filteredTransaction);
}
}
return largestTransaction;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The goal of this function is to find one largest expense, but the result is stored inside an array.

But we don't need to store it into an array, because you did that, you needed extra logic (push / pop).

Keeping a single transaction object for the largest expense would be enough. For example:

export function getLargestExpense() {
  let largest = null;
  for (const transaction of transactions) {
    if (transaction.type === 'expense') {
      if (largest === null || transaction.amount > largest.amount) {
        largest = transaction;
      }
    }
  }
  return largest;
}

Comment on lines +12 to 20
export function getTotalIncome() {
let totalIncome = 0;
for (const transaction of transactions) {
if (transaction.type === 'income') {
totalIncome += transaction.amount;
}
}
return totalIncome;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work👍

Comment on lines +2 to +12
addTransaction,
getTotalIncome,
getTotalExpenses,
getBalance,
getTransactionsByCategory,
getLargestExpense,
printAllTransactions,
printSummary,
getTransactionsByType,
getTotalTransactions,
} from './finance.js';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small suggestion 🙂

Some imported functions are not used in this file.
It’s best practice to remove unused imports to keep the code clean and easier to read.

@mo92othman mo92othman added Reviewed This assignment has been reivewed by a mentor and a feedback has been provided and removed To review labels Feb 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Reviewed This assignment has been reivewed by a mentor and a feedback has been provided

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants