Challenge: Solution Review
This lesson will explain the solution to the problem from the previous coding challenge.
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 ...