Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .hyf/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Auto grade tool

## How it works

1. The auto grade tool runs the `test.sh` script located in this directory.
2. `test.sh` should write to a file named `score.json` with following JSON format:
```json
Expand All @@ -12,4 +13,3 @@
```
All scores are out of 100. It is up to the assignment to determine how to calculate the score.
3. The auto grade runs via a github action on PR creation and updates the PR with the score.

2 changes: 1 addition & 1 deletion .hyf/score.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
"score": 75,
"pass": true,
"passingScore": 50
}
}
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"semi": true,
"singleQuote": true,
"trailingComma": "es5",
"printWidth": 80,
"tabWidth": 2
}
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Core program week 4 assignment

The week 4 assignment for the HackYourFuture Core program can be found at the following link: https://hub.hackyourfuture.nl/core-program-week-4-assignment

## Implementation Instructions
- Implement the requirements in the `finance-tracker` folder.
- Use the existing file structure.

- Implement the requirements in the `finance-tracker` folder.
- Use the existing file structure.
- You are allowed to create additional files if needed.
58 changes: 58 additions & 0 deletions finance-tracker/app.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,61 @@
// This is the entrypoint for your application.
// node app.js
import {
addTransaction,
calculateAverageExpensesPerCategory,
findConsecutiveExpensiveMonth,
getTransactionsByCategory,
groupTransactionByMonth,
printGeneralReport,
removeTransactions,
searchTransactionsByDateRange,
} from './finance.js';
import transactions from './data.js';

const newTransaction = addTransaction({
id: 31,
type: 'expense',
category: 'groceries',
amount: 98,
description: 'Weekly supermarket shopping',
date: '2026-01-25',
});

const transactionsByCategory = getTransactionsByCategory(
transactions,
'groceries'
);

const financeReport = printGeneralReport(transactions);

console.log(newTransaction, transactionsByCategory, financeReport);

//Bonus Challenges output
const transactionsByDateRange = searchTransactionsByDateRange(
transactions,
'2025-01-22',
'2025-02-24'
);

// Node.js collapses nested objects inside arrays and prints them as [Object]. To see the full structure, I use JSON.stringify(). The second argument (null)means no custom replacer, and the third argument (2) adds indentation for readability.

const transactionsGroupedByMonth = JSON.stringify(
groupTransactionByMonth(transactions),
null,
2
);

const averageExpensesPerCategory =
calculateAverageExpensesPerCategory(transactions);

const remainingTransactions = removeTransactions(transactions, 3);

const consecutiveExpensiveMonths = findConsecutiveExpensiveMonth(transactions);

console.log(
transactionsByDateRange,
transactionsGroupedByMonth,
averageExpensesPerCategory,
remainingTransactions,
consecutiveExpensiveMonths
);
205 changes: 204 additions & 1 deletion finance-tracker/data.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,205 @@
// Place here the transaction data array. Use it in your application as needed.
const transactions = [];
const transactions = [
{
id: 1,
type: 'income',
category: 'salary',
amount: 3000,
description: 'Monthly salary',
date: '2025-01-15',
},
{
id: 2,
type: 'expense',
category: 'groceries',
amount: 120,
description: 'Weekly supermarket shopping',
date: '2025-01-16',
},
{
id: 3,
type: 'expense',
category: 'transport',
amount: 45,
description: 'Monthly public transport pass',
date: '2025-01-17',
},
{
id: 4,
type: 'income',
category: 'freelance',
amount: 600,
description: 'Freelance web project',
date: '2025-01-20',
},
{
id: 5,
type: 'expense',
category: 'entertainment',
amount: 75,
description: 'Concert tickets',
date: '2025-01-21',
},
{
id: 6,
type: 'expense',
category: 'utilities',
amount: 150,
description: 'Electricity and water bill',
date: '2025-01-22',
},
{
id: 7,
type: 'income',
category: 'gift',
amount: 200,
description: 'Birthday gift from family',
date: '2025-01-23',
},
{
id: 8,
type: 'expense',
category: 'health',
amount: 90,
description: 'Doctor appointment',
date: '2025-02-24',
},
{
id: 9,
type: 'expense',
category: 'education',
amount: 300,
description: 'Online course fee',
date: '2025-03-15',
},
{
id: 10,
type: 'expense',
category: 'education',
amount: 135,
description: 'Online course fee',
date: '2025-03-25',
},
{
id: 11,
type: 'expense',
category: 'groceries',
amount: 95,
description: 'Weekly supermarket shopping',
date: '2025-02-02',
},
{
id: 12,
type: 'expense',
category: 'transport',
amount: 45,
description: 'Monthly public transport pass',
date: '2025-02-10',
},
{
id: 13,
type: 'income',
category: 'salary',
amount: 3000,
description: 'Monthly salary',
date: '2025-02-15',
},
{
id: 14,
type: 'expense',
category: 'entertainment',
amount: 60,
description: 'Cinema tickets',
date: '2025-02-18',
},
{
id: 15,
type: 'expense',
category: 'utilities',
amount: 155,
description: 'Electricity and water bill',
date: '2025-02-22',
},
{
id: 16,
type: 'income',
category: 'freelance',
amount: 400,
description: 'Small freelance task',
date: '2025-03-05',
},
{
id: 17,
type: 'expense',
category: 'health',
amount: 120,
description: 'Pharmacy purchase',
date: '2025-03-12',
},
{
id: 18,
type: 'expense',
category: 'groceries',
amount: 130,
description: 'Weekly supermarket shopping',
date: '2025-03-20',
},
{
id: 19,
type: 'expense',
category: 'transport',
amount: 50,
description: 'Taxi ride',
date: '2025-03-28',
},
{
id: 20,
type: 'income',
category: 'bonus',
amount: 500,
description: 'Quarterly bonus',
date: '2025-04-01',
},
{
id: 21,
type: 'expense',
category: 'education',
amount: 200,
description: 'Books and materials',
date: '2025-04-03',
},
{
id: 22,
type: 'expense',
category: 'entertainment',
amount: 90,
description: 'Theatre tickets',
date: '2025-04-10',
},
{
id: 23,
type: 'expense',
category: 'utilities',
amount: 160,
description: 'Electricity and water bill',
date: '2025-04-15',
},
{
id: 24,
type: 'expense',
category: 'health',
amount: 80,
description: 'Dentist visit',
date: '2025-04-20',
},
{
id: 25,
type: 'income',
category: 'salary',
amount: 3100,
description: 'Monthly salary',
date: '2025-03-15',
},
];

export default transactions;
Loading