diff --git a/src/transactions.ts b/src/transactions.ts index f1cd836..d37a7ac 100644 --- a/src/transactions.ts +++ b/src/transactions.ts @@ -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: @@ -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: @@ -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[]".