-
-
Save codecademydev/43c7dd8b9f67ccf39fcf59f0663482ee to your computer and use it in GitHub Desktop.
Codecademy export
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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[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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment