add array helper exercise
Neue Datei |
| | |
| | | const revenues = [
|
| | | {month: 0, amount: 1000},
|
| | | {month: 1, amount: 2000},
|
| | | {month: 2, amount: 3000},
|
| | | {month: 3, amount: 4000},
|
| | | {month: 4, amount: 5000},
|
| | | {month: 5, amount: 6000},
|
| | | {month: 6, amount: 6000},
|
| | | {month: 7, amount: 5000},
|
| | | {month: 8, amount: 4000},
|
| | | {month: 9, amount: 3000},
|
| | | {month: 10, amount: 2000},
|
| | | {month: 11, amount: 1000}
|
| | | ];
|
| | |
|
| | | let totalRevenue = 0;
|
| | |
|
| | | totalRevenue = revenues
|
| | | .filter((revenue) => revenue.month < 6)
|
| | | .map((revenue) => revenue.amount)
|
| | | .reduce((sum, amount) => sum + amount, 0);
|
| | |
|
| | | console.log(totalRevenue);
|