Cashregister 7/7 Why employee.discountPercent?


Hello fellows who are in 7/7 or finished it.
could someone explain why are we using emplyee.discountPercent and not StaffMember.discountPercent

what is emplyee? it is neither a method or a class or object.
Thanks for any ideas


employee is a locally defined variable that refers to the staff member object being passed into the function.

We instantiated a me object and gave it a discountPercent value of 20. We calculate the total bill for me by calling the applyStaffDiscount() method, with me as the argument.

Remember, me is not a member of cashRegister like applyStaffDiscount so we need to supply the object to the method.


When we examine the method,

applyStaffDiscount: function (employee) { *= 1 - employee.discountPercent / 100;

See where me comes into play? employee is a direct reference to that object.