-
Notifications
You must be signed in to change notification settings - Fork 0
/
workAround.js
65 lines (49 loc) · 2.01 KB
/
workAround.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//employee.js
let Employee = {
salary : 100000
};
let payGrades = {
entryLevel: { taxMultiplier: .05, benefits: ['health'], minSalary: 10000, maxSalary: 49999 },
midLevel: { taxMultiplier: .1, benefits: ['health', 'housing'], minSalary: 50000, maxSalary: 99999 },
seniorLevel: { taxMultiplier: .2, benefits: ['health', 'housing', 'wellness', 'gym'], minSalary: 100000, maxSalary: 200000 }
};
export function getCadre() {
if (Employee.salary >= payGrades.entryLevel.minSalary && Employee.salary <= payGrades.entryLevel.maxSalary) {
return 'entryLevel';
} else if (Employee.salary >= payGrades.midLevel.minSalary && Employee.salary <= payGrades.midLevel.maxSalary) {
return 'midLevel';
} else return 'seniorLevel';
}
export function calculateTax() {
return payGrades[getCadre()].taxMultiplier * Employee.salary;
}
export function getBenefits() {
return payGrades[getCadre()].benefits.join(', ');
}
export function calculateBonus() {
return .02 * Employee.salary;
}
export function reimbursementEligibility() {
let reimbursementCosts = { health: 5000, housing: 8000, wellness: 6000, gym: 12000 };
let totalBenefitsValue = 0;
let employeeBenefits = payGrades[getCadre()].benefits;
for (let i = 0; i < employeeBenefits.length; i++) {
totalBenefitsValue += reimbursementCosts[employeeBenefits[i]];
}
return totalBenefitsValue;
}
export default Employee;
//workaround.js
import{getCadre, calculateTax, getBenefits, calculateBonus, reimbursementEligibility} from './employee.js';
import Employee from './employee.js';
function getEmployeeInformation(inputSalary) {
Employee.salary = inputSalary;
console.log('Cadre: ' + getCadre());
console.log('Tax: ' + calculateTax());
console.log('Benefits: ' + getBenefits());
console.log('Bonus: ' + calculateBonus());
console.log('Reimbursement Eligibility: ' + reimbursementEligibility() + '\n');
}
getEmployeeInformation(10000);
getEmployeeInformation(50000);
getEmployeeInformation(100000);