Hi,
i’m currently at the last task 17 on the project workAround. My second file ‘workAround’ throws an error and my ‘employee’ file seems to be fine. The error message is included here in the text file.
Thank you in advance!
let Employee = {
salary: 100000
};
export 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[Employee.getCadre()].taxMultiplier * Employee.salary;
}
export function getBenefits() {
return payGrades[Employee.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[Employee.getCadre()].benefits;
for (let i = 0; i < employeeBenefits.length; i++) {
totalBenefitsValue += reimbursementCosts[employeeBenefits[i]];
}
return totalBenefitsValue;
}
export default Employee;
type or paste code here
import { getCadre, calculateTax, getBenefits, calculateBonus, reimbursementEligibility } from ‘./employee’;
import {Employee} from ‘./employee’;
function getEmployeeInformation(salary) {
Employee.salary = salary;
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);
/home/ccuser/workspace/intermediate-javascript_modules-workAround/workAround.js:6
_employee.Employee.salary = salary;
^
TypeError: Cannot set property ‘salary’ of undefined
at getEmployeeInformation (workAround.js:6:3)
at Object. (workAround.js:14:1)
at Module._compile (module.js:571:32)
at loader (/home/ccuser/node_modules/babel-register/lib/node.js:158:5)
at Object.require.extensions.(anonymous function) [as .js] (/home/ccuser/node_modules/babel-register/lib/node.js:168:7)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Function.Module.runMain (module.js:605:10)
at /home/ccuser/node_modules/babel-cli/lib/_babel-node.js:171:48
type or paste code here