const employeesList = ['frontend', 'backend', "designer"];
const salaries = {
frontend: 12000,
backend: 10000,
designer: 8000,
total(staff = []) {
return staff.reduce((salary, employee) => salary + this[employee], 0)
},
dayPay() {
alert('We mush pay salary on Tuesday!');
},
};
console.log(salaries.total(employeesList)) // 30000
salaries.manager = 5000;
employeesList.push('manager');
console.log(salaries.total(employeesList)) // 35000
Чтобы работал require, вам нужно добавить в package.json поле "type": "commonjs",
Для использования import chalk from 'chalk' нужно добавить "type": "module" в package.json