FrontEnd.ro logo
Funcții pe Array-uri / partea 2
let employees = [
  { name: "Alex", salary: 950 },
  { name: "Jon", salary: 1761 },
  { name: "Diana", salary: 1000 }
];

function callbackFn(acc, current) {
  return acc + current.salary;
}

let salaryExpenses = employees.reduce(callbackFn, 0);
console.log(salaryExpenses);