Code violating the DRY principle:
class Employee {
calculateSalaryNet() {
return this.hoursWorked * this.hourlyWage;
}
calculateSalaryGross() {
return this.hoursWorked * this.hourlyWage + TAX;
}
}
Fixed code:
class Employee {
calculateSalaryNet() {
return this.hoursWorked * this.hourlyWage;
}
calculateSalaryGross() {
return this.calculateSalaryNet() + TAX;
}
}