1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
| 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);
|
|