Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e12f62f

Browse files
authored
Fixed duplicate code
The proposed "good" way of coding was actually changing a property's name in the developers object. While one can argue that in this case they could be the same, the point of the example was to show that you can still remove duplicated code that require *different* things.
1 parent 6e7b67b commit e12f62f

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

README.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -439,23 +439,21 @@ function showEmployeeList(employees) {
439439
employees.forEach((employee) => {
440440
const expectedSalary = employee.calculateExpectedSalary();
441441
const experience = employee.getExperience();
442+
443+
let data = {
444+
expectedSalary,
445+
experience
446+
};
442447

443-
let portfolio;
444448
switch (employee.type) {
445449
case 'manager':
446-
portfolio = employee.getMBAProjects();
450+
data.portfolio = employee.getMBAProjects();
447451
break;
448452
case 'developer':
449-
portfolio = employee.getGithubLink();
453+
data.githubLink = employee.getGithubLink();
450454
break;
451455
}
452456

453-
const data = {
454-
expectedSalary,
455-
experience,
456-
portfolio
457-
};
458-
459457
render(data);
460458
});
461459
}

0 commit comments

Comments
 (0)