Hi,
Great Article!
I'm just confused with this instruction on #3. Calculate Employee Gross Pay
Using this base function, create three partial application functions that respectively will calculate the associate, supervisor or admin gross pay when invoked.
I don't think it needs partial application for calculating those 3 roles since the base functions accepts role object already. But it can help to create partial application when computing the grossPay for the total of hourly and overtime.
const getGross = (rate) => (totalHours) => rate * totalHours
const computeGrossSalary = ({
role = {},
totalHours = 0,
overtimeTotalHours = 0
}) => {
const { rate: hourlyRate = 0, overtime: overtimeRate = 0 } = role || {}
const totalHourlySalary = getGross(hourlyRate)
const totalOvertimeSalary = getGross(overtimeRate)
return totalHourlySalary(totalHours) + totalOvertimeSalary(overtimeTotalHours)
}
computeGrossSalary({
role: { roleId: 3, rate: 12.5, overtime: 18.75 },
totalHours: 1
})
BTW I know it's bad to assume and should ask the interviewer if not clear. But I assume that the
rateis hourly not daily.
Please correct me if am wrong.
Cheers!