JavaScript - Object Inheritance
Practinc object inheritance!
by Codi Bezouka-Smith
JavaScript
function Employee (firstName, lastName, deptCode, salary) {
this.firstName = firstName;
this.lastName = lastName;
this.deptCode = deptCode;
this.salary = salary;
}
Employee.prototype.getSummary = () => {
return 'name: ' + this.firstName + ' ' + this.lastName + '\n'
+ 'Dept: ' + this.deptCode + '\n';
};
Employee.prototype.getMonthlySalary = () => {
return Number((this.salary / 12).toFixed(2));
};
Employee.runPayroll = () => {
return this.lastName
+ ', '
+ this.lastName
+ ' $' + this.getMonthlySalary()
+ '\n';
}