Sascha Schulz
2023-06-20 b16e5cf3df81a046ac0114c528ea46ef693ff0fd
add array helper exercise
1 Dateien hinzugefügt
23 ■■■■■ Geänderte Dateien
templates/007-js/revenue.js 23 ●●●●● Patch | Ansicht | Raw | Blame | Historie
templates/007-js/revenue.js
Neue Datei
@@ -0,0 +1,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);