Можно переписать в таком виде
const employees = {
frontend: 12000,
backend: 10000,
designer: 8000,
};
const total = (employees = {}) =>
Object.values(employees).reduce((salary, employeeSalary) => salary + employeeSalary, 0);
console.log(total(employees))
employees.manager = 5000;
console.log(total(employees))
Или если хотите придерживаться вашего варианта то так:
const employeesList = ['frontend', 'backend', "designer"];
const salaries = {
frontend: 12000,
backend: 10000,
designer: 8000,
total: (staff = []) => staff.reduce((salary, employeeSalary) => salary + employeeSalary, 0),
dayPay() {
alert('We mush pay salary on Tuesday!');
},
};
salaries.total(employeesList) // 30000
employees.manager = 5000;
employeesList.push('manager');
salaries.total(employeesList) // 35000