Challenge: Solution Review
Explore the mediator pattern through a solution review where HR coordinates communication between managers and workers. Understand how to implement class interactions and message passing in JavaScript to model organizational workflows.
We'll cover the following...
We'll cover the following...
Solution #
Explanation
In this challenge, you had to use the mediator pattern to implement the HR of an office. HR acts as a communication channel between different employees of a company, such as a manager and the workers.
Let’s start by discussing the HR class.
class HR {
constructor(){
this.employeeList = []
}
//code...
}
The constructor initializes an array employeeList that will contain all the employees in the company.
Next, it has the registerEmployee function that registers an employee by adding them to the list of employees.
registerEmployee(employee){
this.employeeList[employee.name] = employee
}
Next, it defines the ...