Skip to content

Dagim H.#17

Open
Dagim02 wants to merge 2 commits intoHackYourAssignment:mainfrom
Dagim02:main
Open

Dagim H.#17
Dagim02 wants to merge 2 commits intoHackYourAssignment:mainfrom
Dagim02:main

Conversation

@Dagim02
Copy link

@Dagim02 Dagim02 commented Feb 4, 2026

No description provided.

dagimgit config --global user.email dagimvanhaileselassie@gmail.com and others added 2 commits February 4, 2026 20:55
@github-actions
Copy link

github-actions bot commented Feb 4, 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

Copy link

@reposman33 reposman33 left a comment

Choose a reason for hiding this comment

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

Some comments nd one function needs fixing: function getLargestExpense()

// LARGEST EXPENSE & COUNT
const largest = getLargestExpense();
console.log(
`\nLargest Expense: ${chalk.yellow(largest.description)} (${chalk.red('€' + largest.amount)})`,

Choose a reason for hiding this comment

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

in backticks you just can use Return, you don't have to use \n. So

console.log(
\nLargest Expense: ${chalk.yellow(largest.description)} (${chalk.red('€' + largest.amount)})
becomes

console.log( Largest Expense: ${chalk.yellow(largest.description)} (${chalk.red('€' + largest.amount)})

Copy link
Author

Choose a reason for hiding this comment

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

Thank you for the detailed feedback. I realize there were several areas for improvement, specifically regarding object initialization, using built-in array methods like .filter(), removing unnecessary \n escape characters in template literals, and overall code formatting.
I am reviewing all the lessons now and will refactor the code to be more concise and professional. I will resubmit the corrected version with Prettier formatting applied very soon.

`\nLargest Expense: ${chalk.yellow(largest.description)} (${chalk.red('€' + largest.amount)})`,
);
// Use the .length property of the transactions array we imported
const transactions = require('./data');

Choose a reason for hiding this comment

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

Put all imports (require()) at the beginning for clarity

function getTotalIncome() {
// TODO: Implement this function
let total = 0;
for (const tx of transactions) {

Choose a reason for hiding this comment

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

This works fine. A shorter way to reduce an array to a number is to use the reduce function():
const total = transactions.reduce().


function getTotalExpenses() {
// TODO: Implement this function
let total = 0;

Choose a reason for hiding this comment

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

This works fine. A shorter way to reduce an array to a number is to use the reduce function():
const total = transactions.reduce().


function getTransactionsByCategory(category) {
// TODO: Implement this function
const filtered = [];

Choose a reason for hiding this comment

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

This works fine. A shorter way to filter elements from an array is to use the filter function():
const filtered = transactions.filtered().

for (const tx of transactions) {
// Check if it is an expense AND if it's larger than our current record
if (tx.type === 'expense' && tx.amount > largest.amount) {
largest = tx;
Copy link

@reposman33 reposman33 Feb 21, 2026

Choose a reason for hiding this comment

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

this works but it is a bit confusing... why do you first declare

let largest = { amount: 0, description: 'None' };

and in the loop you overwrite largest and have it point to tx;? What do we need { amount: 0, description: 'None' };
for? If you overwrite it anyway, largest can also be 1, or null or false.

Defining largest = { amount: 0, description: 'None' }; makes me expect that aftr the function largest will be { amount: 1200, description: 'rent' }.

Either define largest as null (like Shadi did) or even better, keep largest but make sure that largest.amount and largest description point to the greatest expense after running the function

Copy link
Author

Choose a reason for hiding this comment

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

Thank you for the feedback. I will take the correction regarding the object initialization and format the entire codebase with Prettier. I will resubmit it as soon as possible.

@reposman33 reposman33 added Reviewed This assignment has been reivewed by a mentor and a feedback has been provided and removed Review in progress labels Feb 21, 2026
"url": "https://github.com/Dagim02/c55-core-week-4/issues"
},
"homepage": "https://github.com/Dagim02/c55-core-week-4#readme",
"dependencies": {

Choose a reason for hiding this comment

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

I'm missing prettier...Format entire codebase with Prettier before submission

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