Last active
July 24, 2020 00:40
-
-
Save LFTroya/d9838d334f7e75ba260dfd8913187444 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
['1-2020', '2-2020', '3-2020'].map(shortDate => { | |
const transaction = transactions.find(transaction => `${transaction.month}-${transaction.year}` === shortDate); | |
const {total_incomes, total_expenses, utility_before_taxes} = transaction.details; | |
return {date: shortDate, total_incomes, total_expenses, utility_before_taxes}; | |
}); | |
// [ | |
// {date: '1-2020', total_incomes: 0, total_expenses: 0, utility_before_taxes: 0}, | |
// {date: '2-2020', total_incomes: 0, total_expenses: 0, utility_before_taxes: 0}, | |
// {date: '3-2020', total_incomes: 0, total_expenses: 0, utility_before_taxes: 0} | |
// ] | |
// Or you can transform transactions | |
transactions.map(transaction => { | |
const {total_incomes, total_expenses, utility_before_taxes} = transaction.details; | |
return {date: `${transaction.month}-${transaction.year}`, total_incomes, total_expenses, utility_before_taxes}; | |
}); | |
// Exact result but for the range | |
// [ | |
// {date: '1-2020', total_incomes: 0, total_expenses: 0, utility_before_taxes: 0}, | |
// {date: '2-2020', total_incomes: 0, total_expenses: 0, utility_before_taxes: 0}, | |
// {date: '3-2020', total_incomes: 0, total_expenses: 0, utility_before_taxes: 0} | |
// ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment