// 1. Find the with id 20
const employeeWithId20 = employees.find(employee => employee.id === 20);
console.log(employeeWithId20);

// 2. Find all employees with role "Manager"
const managers = employees.filter(employee => employee.role === 'Manager');
console.log(managers);

// 3. Check if there any employee with role "CEO"
const isAnyEmployeeCEO = employees.some(employee => employee.role === 'CEO');
console.log(isAnyEmployeeCEO);

// 4. Make sure that all employees are older than 18
const areAllEmployeesOlderThan18 = employees.every(employee => employee.age > 18);
console.log(areAllEmployeesOlderThan18);

// 5. Calculate the total wages we are paying the employees
const totalWages = employees.reduce((acc, employee) => acc + employee.salary, 0);
console.log(totalWages);

// 6. How many employees each role has and what is the total wages paid for each role
const roles = employees.reduce((acc, employee) => {
    if (!acc[employee.role]) {
        acc[employee.role] = { count: 0, salary: 0, avg: 0 };
    }
    acc[employee.role].count++;
    acc[employee.role].salary += employee.salary;
    acc[employee.role].avg = acc[employee.role].salary / acc[employee.role].count;
    return acc;
}, {});
console.log(roles);

// 7. Modify the items in the array to also include the full name of the employee
const employeesWithFullName = employees.map(employee => ({
    ...employee,
    fullName: `${employee.first_name} ${employee.lastname}`,
}));
console.log(employeesWithFullName);

// 8. Say hello to each employee
employeesWithFullName.forEach(employee => console.log(`Hello ${employee.fullName}`));