Skip to content
Open
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
16 changes: 9 additions & 7 deletions src/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ const transactions: Transaction[] = [
// example:
// filterIncomeTransactions(transactions); // => [["income", 1000], ["income", 1500], ["income", 700]]
function filterIncomeTransactions(transactions: Transaction[]): Transaction[] {
// write your code here...

return []; // replace empty array with what you see is fit
return transactions.filter(([type]) => type == "income"); // replace empty array with what you see is fit
}

// `filterExpenseTransactions` function that:
Expand All @@ -33,7 +31,7 @@ function filterIncomeTransactions(transactions: Transaction[]): Transaction[] {
function filterExpenseTransactions(transactions: Transaction[]): Transaction[] {
// write your code here...

return []; // replace empty array with what you see is fit
return transactions.filter(([type]) => type == "expense"); // replace empty array with what you see is fit
}

// `calculateTotalIncome` function that:
Expand All @@ -42,10 +40,14 @@ function filterExpenseTransactions(transactions: Transaction[]): Transaction[] {
// example:
// calculateTotalIncome(transactions); // => 3200 (1000 + 1500 + 700)
function calculateTotalIncome(transactions: Transaction[]): number {
// write your code here...

return -1; // replace -1 with what you see is fit
let total = 0;
const incomeArray = filterIncomeTransactions(transactions);
// incomeArray.forEach(([type, ]));
console.log("filtered array: ", incomeArray);
return 0; // replace -1 with what you see is fit
}
// i want to use forEach to exceed to all the values inside the array
// i need a new variable to put the valus in it which is "results"

// `calculateTotalExpenses` function that:
// - Accepts a "transactions" parameter of type "Transaction[]".
Expand Down
Loading